This is an automated email from the ASF dual-hosted git repository.

enorman pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests.git


The following commit(s) were added to refs/heads/master by this push:
     new 266dad5  SLING-7831 support injecting custom/alternate PostResponse 
implementations for the servlets in the usermanager and accessmanager bundles
266dad5 is described below

commit 266dad5127c468b0e6233c4f49b34be56ee629e0
Author: Eric Norman <[email protected]>
AuthorDate: Sun Aug 19 13:39:39 2018 -0700

    SLING-7831 support injecting custom/alternate PostResponse
    implementations for the servlets in the usermanager and accessmanager
    bundles
---
 .../accessManager/ModifyAceTest.java               | 24 +++++++++++--
 .../accessManager/RemoveAcesTest.java              | 18 ++++++++++
 .../userManager/CreateGroupTest.java               | 18 ++++++++++
 .../userManager/CreateUserTest.java                | 18 ++++++++++
 .../userManager/RemoveAuthorizablesTest.java       | 33 ++++++++++++++++-
 .../userManager/UpdateGroupTest.java               | 18 ++++++++++
 .../userManager/UpdateUserTest.java                | 42 ++++++++++++++++++++--
 7 files changed, 166 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
index de28a63..298f3d3 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
@@ -17,9 +17,9 @@
 package org.apache.sling.launchpad.webapp.integrationtest.accessManager;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertFalse;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -40,7 +40,6 @@ import 
org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.junit.experimental.categories.Category;
 
 /**
  * Tests for the 'modifyAce' Sling Post Operation
@@ -137,6 +136,27 @@ public class ModifyAceTest {
                assertEquals("jcr:write", deniedArray.getString(0));
        }
 
+       /**
+        * Test for SLING-7831
+        */
+       @Test 
+       public void testModifyAceCustomPostResponse() throws IOException, 
JsonException {
+               testUserId = H.createTestUser();
+               
+               testFolderUrl = H.createTestFolder();
+               
+        String postUrl = testFolderUrl + ".modifyAce.html";
+
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair("principalId", testUserId));
+               postParams.add(new NameValuePair("privilege@jcr:read", 
"granted"));
+               
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = H.getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }       
+
        @Test 
        public void testModifyAceForGroup() throws IOException, JsonException {
                testGroupId = H.createTestGroup();
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
index 87fffa9..5eb8e05 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.sling.commons.testing.integration.HttpTest;
 import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
 
 /**
@@ -159,6 +160,23 @@ public class RemoveAcesTest extends AccessManagerTestUtil {
                assertEquals(0, jsonObject.size());
        }
 
+       /**
+        * Test for SLING-7831
+        */
+       public void testRemoveAceCustomPostResponse() throws IOException, 
JsonException {
+               String folderUrl = createFolderWithAces(false);
+               
+               //remove the ace for the testUser principal
+               String postUrl = folderUrl + ".deleteAce.html"; 
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair(":applyTo", testUserId));
+
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+       
        //test removing multiple aces
        public void testRemoveAces() throws IOException, JsonException {
                String folderUrl = createFolderWithAces(true);
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java
index dfe7e00..dcb2eb6 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.sling.commons.testing.integration.HttpTest;
 import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
 
 /**
@@ -68,6 +69,23 @@ public class CreateGroupTest extends UserManagerTestUtil {
                assertEquals(testGroupId, jsonObj.getString("marker"));
        }
 
+       /**
+        * Test for SLING-7831
+        */
+       public void testCreateGroupCustomPostResponse() throws IOException, 
JsonException {
+        String postUrl = HTTP_BASE_URL + 
"/system/userManager/group.create.html";
+
+               testGroupId = "testGroup" + random.nextInt();
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair(":name", testGroupId));
+               postParams.add(new NameValuePair("marker", testGroupId));
+
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        public void testCreateGroupMissingGroupId() throws IOException {
         String postUrl = HTTP_BASE_URL + 
"/system/userManager/group.create.html";
 
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
index 0401dbd..7a50492 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java
@@ -232,4 +232,22 @@ public class CreateUserTest {
                JsonObject jsonObj = JsonUtil.parseObject(json);
                assertNotNull(jsonObj);
        }
+
+       /**
+        * Test for SLING-7831
+        */
+       @Test 
+       public void testCreateUserCustomPostResponse() throws IOException, 
JsonException {
+        String postUrl = HttpTest.HTTP_BASE_URL + 
"/system/userManager/user.create.html";
+
+               testUserId = "testUser" + random.nextInt();
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair(":name", testUserId));
+               postParams.add(new NameValuePair("pwd", "testPwd"));
+               postParams.add(new NameValuePair("pwdConfirm", "testPwd"));
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = H.getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
 }
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java
index 040795e..de29bd3 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.sling.commons.testing.integration.HttpTest;
 import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
 
 /**
@@ -49,7 +50,22 @@ public class RemoveAuthorizablesTest extends 
UserManagerTestUtil {
                getUrl = HTTP_BASE_URL + "/system/userManager/user/" + userId + 
".json";
                assertAuthenticatedHttpStatus(creds, getUrl, 
HttpServletResponse.SC_NOT_FOUND, null); //make sure the profile request 
returns some data
        }
-       
+
+       /**
+        * Test for SLING-7831
+        */
+       public void testRemoveUserCustomPostResponse() throws IOException {
+               String userId = createTestUser();
+               
+               String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + 
userId + ".delete.html";
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        public void testRemoveGroup() throws IOException {
                String groupId = createTestGroup();
                
@@ -66,6 +82,21 @@ public class RemoveAuthorizablesTest extends 
UserManagerTestUtil {
                assertAuthenticatedHttpStatus(creds, getUrl, 
HttpServletResponse.SC_NOT_FOUND, null); //make sure the profile request 
returns some data
        }
 
+       /**
+        * Test for SLING-7831
+        */
+       public void testRemoveGroupCustomPostResponse() throws IOException {
+               String groupId = createTestGroup();
+               
+               String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + 
groupId + ".delete.html";
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        public void testRemoveAuthorizables() throws IOException {
                String userId = createTestUser();
                String groupId = createTestGroup();
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java
index 73c797a..45da8e9 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java
@@ -28,6 +28,7 @@ import javax.servlet.http.HttpServletResponse;
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.NameValuePair;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.sling.commons.testing.integration.HttpTest;
 import org.apache.sling.launchpad.webapp.integrationtest.util.JsonUtil;
 
 /**
@@ -81,6 +82,23 @@ public class UpdateGroupTest extends UserManagerTestUtil {
                assertEquals("http://www.apache.org/updated";, 
jsonObj.getString("url"));
        }
 
+       /**
+        * Test for SLING-7831
+        */
+       public void testUpdateGroupCustomPostResponse() throws IOException, 
JsonException {
+               testGroupId = createTestGroup();
+
+        String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + 
testGroupId + ".update.html";
+
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair("displayName", "My Updated 
Test Group"));
+
+               Credentials creds = new UsernamePasswordCredentials("admin", 
"admin");
+               String content = getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        public void testUpdateGroupMembers() throws IOException, JsonException {
                testGroupId = createTestGroup();
                testUserId = createTestUser();
diff --git 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java
 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java
index 2d1a305..1dc50cd 100644
--- 
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java
+++ 
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java
@@ -96,7 +96,25 @@ public class UpdateUserTest {
         jsonObj = JsonUtil.parseObject(json);
         assertEquals("value", jsonObj.getString("param"));
        }
-       
+
+       /**
+        * Test for SLING-7831
+        */
+       @Test 
+       public void testUpdateUserCustomPostResponse() throws IOException {
+               testUserId = H.createTestUser();
+               
+        String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" 
+ testUserId + ".update.html";
+
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair("displayName", "My Updated 
Test User"));
+
+               Credentials creds = new UsernamePasswordCredentials(testUserId, 
"testPwd");
+               String content = H.getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        @Test 
        public void testChangeUserPassword() throws IOException {
                testUserId = H.createTestUser();
@@ -111,7 +129,27 @@ public class UpdateUserTest {
                Credentials creds = new UsernamePasswordCredentials(testUserId, 
"testPwd");
                H.assertAuthenticatedPostStatus(creds, postUrl, 
HttpServletResponse.SC_OK, postParams, null);
        }
-       
+
+       /**
+        * Test for SLING-7831
+        */
+       @Test 
+       public void testChangeUserPasswordCustomPostResponse() throws 
IOException {
+               testUserId = H.createTestUser();
+               
+        String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" 
+ testUserId + ".changePassword.html";
+
+               List<NameValuePair> postParams = new ArrayList<NameValuePair>();
+        postParams.add(new NameValuePair(":responseType", "custom"));
+               postParams.add(new NameValuePair("oldPwd", "testPwd"));
+               postParams.add(new NameValuePair("newPwd", "testNewPwd"));
+               postParams.add(new NameValuePair("newPwdConfirm", 
"testNewPwd"));
+
+               Credentials creds = new UsernamePasswordCredentials(testUserId, 
"testPwd");
+               String content = H.getAuthenticatedPostContent(creds, postUrl, 
HttpTest.CONTENT_TYPE_HTML, postParams, HttpServletResponse.SC_OK);
+               assertEquals("Thanks!", content); //verify that the content 
matches the custom response
+       }
+
        @Test 
        public void testChangeUserPasswordWrongOldPwd() throws IOException {
                testUserId = H.createTestUser();

Reply via email to