Return-Path: X-Original-To: apmail-sling-commits-archive@www.apache.org Delivered-To: apmail-sling-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5887410E76 for ; Tue, 5 Nov 2013 14:34:47 +0000 (UTC) Received: (qmail 85663 invoked by uid 500); 5 Nov 2013 14:34:44 -0000 Delivered-To: apmail-sling-commits-archive@sling.apache.org Received: (qmail 85578 invoked by uid 500); 5 Nov 2013 14:34:41 -0000 Mailing-List: contact commits-help@sling.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@sling.apache.org Delivered-To: mailing list commits@sling.apache.org Received: (qmail 85567 invoked by uid 99); 5 Nov 2013 14:34:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 14:34:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 05 Nov 2013 14:34:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5FEB723888E7; Tue, 5 Nov 2013 14:34:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1539010 - in /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest: ./ accessManager/ servlets/post/ userManager/ Date: Tue, 05 Nov 2013 14:34:14 -0000 To: commits@sling.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131105143415.5FEB723888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bdelacretaz Date: Tue Nov 5 14:34:14 2013 New Revision: 1539010 URL: http://svn.apache.org/r1539010 Log: SLING-3229 - give different names to our two PrivilegesInfoTest classes, convert to JUnit4 style and disable some tests for Oak with JackrabbitOnly category Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AuthenticatedTestUtil.java - copied, changed from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessManagerTestUtil.java - copied, changed from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessPrivilegesInfoTest.java - copied, changed from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/PrivilegesInfoTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserManagerTestUtil.java - copied, changed from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/AbstractUserManagerTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java - copied, changed from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/PrivilegesInfoTest.java Removed: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/PrivilegesInfoTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/AbstractUserManagerTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/PrivilegesInfoTest.java Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NamespaceMappingTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPrivilegesUpdateTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AuthenticatedTestUtil.java (from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java) URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AuthenticatedTestUtil.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AuthenticatedTestUtil.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java&r1=1538905&r2=1539010&rev=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AbstractAuthenticatedTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/AuthenticatedTestUtil.java Tue Nov 5 14:34:14 2013 @@ -32,22 +32,22 @@ import org.apache.commons.httpclient.Use import org.apache.commons.httpclient.auth.AuthScope; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.sling.commons.testing.integration.HttpTestBase; +import org.apache.sling.commons.testing.integration.HttpTest; /** - * This class consists of utility methods for writing tests which use authentication. + * Utility class for tests which use authentication. */ -public abstract class AbstractAuthenticatedTest extends HttpTestBase { +public class AuthenticatedTestUtil extends HttpTest { /** Execute a POST request and check status */ - protected void assertAuthenticatedAdminPostStatus(String url, int expectedStatusCode, List postParams, String assertMessage) + public void assertAuthenticatedAdminPostStatus(String url, int expectedStatusCode, List postParams, String assertMessage) throws IOException { Credentials defaultcreds = new UsernamePasswordCredentials("admin", "admin"); assertAuthenticatedPostStatus(defaultcreds, url, expectedStatusCode, postParams, assertMessage); } /** Execute a POST request and check status */ - protected void assertAuthenticatedPostStatus(Credentials creds, String url, int expectedStatusCode, List postParams, String assertMessage) + public void assertAuthenticatedPostStatus(Credentials creds, String url, int expectedStatusCode, List postParams, String assertMessage) throws IOException { final PostMethod post = new PostMethod(url); post.setFollowRedirects(false); @@ -77,7 +77,7 @@ public abstract class AbstractAuthentica /** Verify that given URL returns expectedStatusCode * @throws IOException */ - protected void assertAuthenticatedHttpStatus(Credentials creds, String urlString, int expectedStatusCode, String assertMessage) throws IOException { + public void assertAuthenticatedHttpStatus(Credentials creds, String urlString, int expectedStatusCode, String assertMessage) throws IOException { URL baseUrl = new URL(HTTP_BASE_URL); AuthScope authScope = new AuthScope(baseUrl.getHost(), baseUrl.getPort(), AuthScope.ANY_REALM); GetMethod getMethod = new GetMethod(urlString); @@ -102,7 +102,7 @@ public abstract class AbstractAuthentica * @param expectedContentType use CONTENT_TYPE_DONTCARE if must not be checked * @throws IOException * @throws HttpException */ - protected String getAuthenticatedContent(Credentials creds, String url, String expectedContentType, List params, int expectedStatusCode) throws IOException { + public String getAuthenticatedContent(Credentials creds, String url, String expectedContentType, List params, int expectedStatusCode) throws IOException { final GetMethod get = new GetMethod(url); URL baseUrl = new URL(HTTP_BASE_URL); @@ -157,7 +157,7 @@ public abstract class AbstractAuthentica * @param expectedContentType use CONTENT_TYPE_DONTCARE if must not be checked * @throws IOException * @throws HttpException */ - protected String getAuthenticatedPostContent(Credentials creds, String url, String expectedContentType, List postParams, int expectedStatusCode) throws IOException { + public String getAuthenticatedPostContent(Credentials creds, String url, String expectedContentType, List postParams, int expectedStatusCode) throws IOException { final PostMethod post = new PostMethod(url); URL baseUrl = new URL(HTTP_BASE_URL); @@ -218,7 +218,7 @@ public abstract class AbstractAuthentica return val; } - protected String createTestUser() throws IOException { + public String createTestUser() throws IOException { String postUrl = HTTP_BASE_URL + "/system/userManager/user.create.html"; String testUserId = "testUser" + getNextInt(); @@ -237,7 +237,7 @@ public abstract class AbstractAuthentica return testUserId; } - protected String createTestGroup() throws IOException { + public String createTestGroup() throws IOException { String postUrl = HTTP_BASE_URL + "/system/userManager/group.create.html"; String testGroupId = "testGroup" + getNextInt(); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NamespaceMappingTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NamespaceMappingTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NamespaceMappingTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/NamespaceMappingTest.java Tue Nov 5 14:34:14 2013 @@ -27,7 +27,7 @@ import org.apache.commons.httpclient.Nam /** * Test that both Sling-Namespaces and {@link NamespaceMapper} work. */ -public class NamespaceMappingTest extends AbstractAuthenticatedTest { +public class NamespaceMappingTest extends AuthenticatedTestUtil { /** * Verify that Sling-Namespaces works. @@ -74,7 +74,7 @@ public class NamespaceMappingTest extend String testUserId = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; @@ -87,7 +87,7 @@ public class NamespaceMappingTest extend } @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); this.testUserId = createTestUser(); } Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessManagerTestUtil.java (from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java) URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessManagerTestUtil.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessManagerTestUtil.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java&r1=1538905&r2=1539010&rev=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AbstractAccessManagerTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessManagerTestUtil.java Tue Nov 5 14:34:14 2013 @@ -24,19 +24,21 @@ import java.util.Random; import javax.servlet.http.HttpServletResponse; -import org.apache.sling.launchpad.webapp.integrationtest.AbstractAuthenticatedTest; +import org.apache.sling.launchpad.webapp.integrationtest.AuthenticatedTestUtil; import org.apache.sling.servlets.post.SlingPostConstants; /** - * Base class for AccessManager tests. + * Base class for AccessManager tests - it's called "Util" now + * as we're moving tests to JUnit4-style which won't extend + * this anymore - but right now some still do. */ -public abstract class AbstractAccessManagerTest extends AbstractAuthenticatedTest { +public class AccessManagerTestUtil extends AuthenticatedTestUtil { public static final String TEST_BASE_PATH = "/sling-tests"; private static Random random = new Random(System.currentTimeMillis()); - protected String createTestFolder() throws IOException { + public String createTestFolder() throws IOException { String postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + "testFolder" + random.nextInt(); final String location = testClient.createNode(postUrl + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); @@ -50,7 +52,7 @@ public abstract class AbstractAccessMana return location; } - protected String createTestFolder(String jsonContent) throws IOException { + public String createTestFolder(String jsonContent) throws IOException { final String testPath = TEST_BASE_PATH; Map props = new HashMap(); String testNode = testClient.createNode(HTTP_BASE_URL + testPath, props); @@ -77,11 +79,11 @@ public abstract class AbstractAccessMana return location; } - protected void assertPrivilege(Collection privileges, boolean expected, String privilegeName) { + public void assertPrivilege(Collection privileges, boolean expected, String privilegeName) { if(expected != privileges.contains(privilegeName)) { fail("Expected privilege " + privilegeName + " to be " + (expected ? "included" : "NOT INCLUDED") + " in supplied list: " + privileges + ")"); } } -} +} \ No newline at end of file Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessPrivilegesInfoTest.java (from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/PrivilegesInfoTest.java) URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessPrivilegesInfoTest.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessPrivilegesInfoTest.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/PrivilegesInfoTest.java&r1=1538905&r2=1539010&rev=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/PrivilegesInfoTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/AccessPrivilegesInfoTest.java Tue Nov 5 14:34:14 2013 @@ -16,6 +16,9 @@ */ package org.apache.sling.launchpad.webapp.integrationtest.accessManager; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; @@ -30,34 +33,37 @@ import org.apache.commons.httpclient.Nam import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.JSONObject; +import org.apache.sling.commons.testing.integration.HttpTest; import org.apache.sling.servlets.post.SlingPostConstants; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; -/** - * Tests for the PrivilegesInfo Script Helper - */ -public class PrivilegesInfoTest extends AbstractAccessManagerTest { +public class AccessPrivilegesInfoTest { private static Random random = new Random(System.currentTimeMillis()); String testUserId = null; String testGroupId = null; String testFolderUrl = null; Set toDelete = new HashSet(); + + private final AccessManagerTestUtil H = new AccessManagerTestUtil(); - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public void setup() throws Exception { + H.setUp(); // Script for server-side PrivilegeInfo calculations String scriptPath = "/apps/nt/unstructured"; - testClient.mkdirs(WEBDAV_BASE_URL, scriptPath); - toDelete.add(uploadTestScript(scriptPath, + H.getTestClient().mkdirs(HttpTest.WEBDAV_BASE_URL, scriptPath); + toDelete.add(H.uploadTestScript(scriptPath, "accessmanager/privileges-info.json.esp", "privileges-info.json.esp")); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void cleanup() throws Exception { + H.tearDown(); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); @@ -66,32 +72,33 @@ public class PrivilegesInfoTest extends String postUrl = testFolderUrl; List postParams = new ArrayList(); postParams.add(new NameValuePair(":operation", "delete")); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } if (testGroupId != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } if (testUserId != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } for(String script : toDelete) { - testClient.delete(script); + H.getTestClient().delete(script); } } /* * testuser granted read / denied write */ + @Test public void testDeniedWriteForUser() throws IOException, JSONException { - testUserId = createTestUser(); - testFolderUrl = createTestFolder(); + testUserId = H.createTestUser(); + testFolderUrl = H.createTestFolder(); //assign some privileges String postUrl = testFolderUrl + ".modifyAce.html"; @@ -103,14 +110,14 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("privilege@jcr:write", "denied")); Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); String getUrl = testFolderUrl + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -125,9 +132,10 @@ public class PrivilegesInfoTest extends /* * testuser granted read / granted write */ + @Test public void testGrantedWriteForUser() throws IOException, JSONException { - testUserId = createTestUser(); - testFolderUrl = createTestFolder(); + testUserId = H.createTestUser(); + testFolderUrl = H.createTestFolder(); //assign some privileges String postUrl = testFolderUrl + ".modifyAce.html"; @@ -140,14 +148,14 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "granted")); Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); String getUrl = testFolderUrl + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -160,17 +168,17 @@ public class PrivilegesInfoTest extends assertEquals(true, jsonObj.getBoolean("canModifyAccessControl")); //add a child node to verify the 'canDelete' use case - String childFolderUrl = testClient.createNode(testFolderUrl + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); + String childFolderUrl = H.getTestClient().createNode(testFolderUrl + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); String childPostUrl = childFolderUrl + ".modifyAce.html"; postParams = new ArrayList(); postParams.add(new NameValuePair("principalId", testUserId)); postParams.add(new NameValuePair("privilege@jcr:read", "granted")); postParams.add(new NameValuePair("privilege@jcr:removeNode", "granted")); - assertAuthenticatedPostStatus(adminCreds, childPostUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, childPostUrl, HttpServletResponse.SC_OK, postParams, null); String childGetUrl = childFolderUrl + ".privileges-info.json"; - String childJson = getAuthenticatedContent(testUserCreds, childGetUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String childJson = H.getAuthenticatedContent(testUserCreds, childGetUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(childJson); JSONObject childJsonObj = new JSONObject(childJson); assertEquals(true, childJsonObj.getBoolean("canDelete")); @@ -181,18 +189,19 @@ public class PrivilegesInfoTest extends /* * group testuser granted read / denied write */ + @Test public void testDeniedWriteForGroup() throws IOException, JSONException { - testGroupId = createTestGroup(); - testUserId = createTestUser(); - testFolderUrl = createTestFolder(); + testGroupId = H.createTestGroup(); + testUserId = H.createTestUser(); + testFolderUrl = H.createTestFolder(); Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin"); //add testUserId to testGroup - String groupPostUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; + String groupPostUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; List groupPostParams = new ArrayList(); groupPostParams.add(new NameValuePair(":member", testUserId)); - assertAuthenticatedPostStatus(adminCreds, groupPostUrl, HttpServletResponse.SC_OK, groupPostParams, null); + H.assertAuthenticatedPostStatus(adminCreds, groupPostUrl, HttpServletResponse.SC_OK, groupPostParams, null); //assign some privileges String postUrl = testFolderUrl + ".modifyAce.html"; @@ -203,14 +212,14 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("privilege@jcr:readAccessControl", "granted")); postParams.add(new NameValuePair("privilege@jcr:write", "denied")); - assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); String getUrl = testFolderUrl + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -225,18 +234,19 @@ public class PrivilegesInfoTest extends /* * group testuser granted read / granted write */ + @Test public void testGrantedWriteForGroup() throws IOException, JSONException { - testGroupId = createTestGroup(); - testUserId = createTestUser(); - testFolderUrl = createTestFolder(); + testGroupId = H.createTestGroup(); + testUserId = H.createTestUser(); + testFolderUrl = H.createTestFolder(); Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin"); //add testUserId to testGroup - String groupPostUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; + String groupPostUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; List groupPostParams = new ArrayList(); groupPostParams.add(new NameValuePair(":member", testUserId)); - assertAuthenticatedPostStatus(adminCreds, groupPostUrl, HttpServletResponse.SC_OK, groupPostParams, null); + H.assertAuthenticatedPostStatus(adminCreds, groupPostUrl, HttpServletResponse.SC_OK, groupPostParams, null); //assign some privileges String postUrl = testFolderUrl + ".modifyAce.html"; @@ -248,14 +258,14 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("privilege@jcr:readAccessControl", "granted")); postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "granted")); - assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); String getUrl = testFolderUrl + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -269,17 +279,17 @@ public class PrivilegesInfoTest extends //add a child node to verify the 'canDelete' use case - String childFolderUrl = testClient.createNode(testFolderUrl + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); + String childFolderUrl = H.getTestClient().createNode(testFolderUrl + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); String childPostUrl = childFolderUrl + ".modifyAce.html"; postParams = new ArrayList(); postParams.add(new NameValuePair("principalId", testGroupId)); postParams.add(new NameValuePair("privilege@jcr:read", "granted")); postParams.add(new NameValuePair("privilege@jcr:removeNode", "granted")); - assertAuthenticatedPostStatus(adminCreds, childPostUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, childPostUrl, HttpServletResponse.SC_OK, postParams, null); String childGetUrl = childFolderUrl + ".privileges-info.json"; - String childJson = getAuthenticatedContent(testUserCreds, childGetUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String childJson = H.getAuthenticatedContent(testUserCreds, childGetUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(childJson); JSONObject childJsonObj = new JSONObject(childJson); assertEquals(true, childJsonObj.getBoolean("canDelete")); @@ -289,8 +299,9 @@ public class PrivilegesInfoTest extends /** * Test the fix for SLING-1090 */ + @Test public void testSLING_1090() throws Exception { - testUserId = createTestUser(); + testUserId = H.createTestUser(); //grant jcr: removeChildNodes to the root node ArrayList postParams = new ArrayList(); @@ -298,10 +309,10 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("privilege@jcr:read", "granted")); postParams.add(new NameValuePair("privilege@jcr:removeChildNodes", "granted")); Credentials adminCreds = new UsernamePasswordCredentials("admin", "admin"); - assertAuthenticatedPostStatus(adminCreds, HTTP_BASE_URL + "/.modifyAce.html", HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, HttpTest.HTTP_BASE_URL + "/.modifyAce.html", HttpServletResponse.SC_OK, postParams, null); //create a node as a child of the root folder - testFolderUrl = testClient.createNode(HTTP_BASE_URL + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); + testFolderUrl = H.getTestClient().createNode(HttpTest.HTTP_BASE_URL + "/testFolder" + random.nextInt() + SlingPostConstants.DEFAULT_CREATE_SUFFIX, null); String postUrl = testFolderUrl + ".modifyAce.html"; //grant jcr:removeNode to the test node @@ -309,12 +320,12 @@ public class PrivilegesInfoTest extends postParams.add(new NameValuePair("principalId", testUserId)); postParams.add(new NameValuePair("privilege@jcr:read", "granted")); postParams.add(new NameValuePair("privilege@jcr:removeNode", "granted")); - assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(adminCreds, postUrl, HttpServletResponse.SC_OK, postParams, null); //fetch the JSON for the test page to verify the settings. String getUrl = testFolderUrl + ".privileges-info.json"; Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); assertEquals(true, jsonObj.getBoolean("canDelete")); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/GetAclTest.java Tue Nov 5 14:34:14 2013 @@ -34,13 +34,13 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'acl' and 'eacl' Sling Get Operation */ -public class GetAclTest extends AbstractAccessManagerTest { +public class GetAclTest extends AccessManagerTestUtil { String testUserId = null; String testUserId2 = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { super.tearDown(); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java Tue Nov 5 14:34:14 2013 @@ -34,7 +34,7 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'modifyAce' Sling Post Operation */ -public class ModifyAceTest extends AbstractAccessManagerTest { +public class ModifyAceTest extends AccessManagerTestUtil { String testUserId = null; String testUserId2 = null; @@ -42,7 +42,7 @@ public class ModifyAceTest extends Abstr String testFolderUrl = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { super.tearDown(); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/RemoveAcesTest.java Tue Nov 5 14:34:14 2013 @@ -32,13 +32,13 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'removeAce' Sling POST operation */ -public class RemoveAcesTest extends AbstractAccessManagerTest { +public class RemoveAcesTest extends AccessManagerTestUtil { String testUserId = null; String testGroupId = null; String testFolderUrl = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { super.tearDown(); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPrivilegesUpdateTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPrivilegesUpdateTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPrivilegesUpdateTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletPrivilegesUpdateTest.java Tue Nov 5 14:34:14 2013 @@ -41,16 +41,16 @@ import org.apache.sling.commons.json.JSO import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.JSONObject; import org.apache.sling.commons.testing.integration.NameValuePairList; -import org.apache.sling.launchpad.webapp.integrationtest.AbstractAuthenticatedTest; +import org.apache.sling.launchpad.webapp.integrationtest.AuthenticatedTestUtil; import org.apache.sling.servlets.post.SlingPostConstants; -public class PostServletPrivilegesUpdateTest extends AbstractAuthenticatedTest { +public class PostServletPrivilegesUpdateTest extends AuthenticatedTestUtil { public static final String TEST_BASE_PATH = "/sling-tests"; private String postUrl; private String testUserId = null; @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis(); } @@ -59,7 +59,7 @@ public class PostServletPrivilegesUpdate * @see org.apache.sling.commons.testing.integration.HttpTestBase#tearDown() */ @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletUpdateTest.java Tue Nov 5 14:34:14 2013 @@ -41,17 +41,17 @@ import org.apache.sling.commons.json.JSO import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.JSONObject; import org.apache.sling.commons.testing.integration.NameValuePairList; -import org.apache.sling.launchpad.webapp.integrationtest.AbstractAuthenticatedTest; +import org.apache.sling.launchpad.webapp.integrationtest.AuthenticatedTestUtil; import org.apache.sling.servlets.post.SlingPostConstants; /** Test node updates via the MicrojaxPostServlet */ -public class PostServletUpdateTest extends AbstractAuthenticatedTest { +public class PostServletUpdateTest extends AuthenticatedTestUtil { public static final String TEST_BASE_PATH = "/sling-tests"; private String postUrl; private String testUserId = null; @Override - protected void setUp() throws Exception { + public void setUp() throws Exception { super.setUp(); postUrl = HTTP_BASE_URL + TEST_BASE_PATH + "/" + System.currentTimeMillis(); } @@ -61,7 +61,7 @@ public class PostServletUpdateTest exten * @see org.apache.sling.commons.testing.integration.HttpTestBase#tearDown() */ @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateGroupTest.java Tue Nov 5 14:34:14 2013 @@ -32,13 +32,13 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'createGroup' Sling Post Operation */ -public class CreateGroupTest extends AbstractUserManagerTest { +public class CreateGroupTest extends UserManagerTestUtil { private static Random random = new Random(System.currentTimeMillis()); String testGroupId = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testGroupId != null) { //remove the test group if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".delete.html"; Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/CreateUserTest.java Tue Nov 5 14:34:14 2013 @@ -32,12 +32,12 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'createUser' Sling Post Operation */ -public class CreateUserTest extends AbstractUserManagerTest { +public class CreateUserTest extends UserManagerTestUtil { private static Random random = new Random(System.currentTimeMillis()); private String testUserId; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/RemoveAuthorizablesTest.java Tue Nov 5 14:34:14 2013 @@ -31,7 +31,7 @@ import org.apache.sling.commons.json.JSO /** * Tests for the 'removeAuthorizable' Sling Post Operation */ -public class RemoveAuthorizablesTest extends AbstractUserManagerTest { +public class RemoveAuthorizablesTest extends UserManagerTestUtil { public void testRemoveUser() throws IOException { String userId = createTestUser(); Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateGroupTest.java Tue Nov 5 14:34:14 2013 @@ -33,14 +33,14 @@ import org.apache.sling.commons.json.JSO * Tests for the 'updateAuthorizable' Sling Post Operation on * a group resource. */ -public class UpdateGroupTest extends AbstractUserManagerTest { +public class UpdateGroupTest extends UserManagerTestUtil { String testGroupId = null; String testUserId = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; Modified: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java?rev=1539010&r1=1539009&r2=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UpdateUserTest.java Tue Nov 5 14:34:14 2013 @@ -33,12 +33,12 @@ import org.apache.sling.commons.json.JSO * Tests for the 'updateAuthorizable' and 'changePassword' Sling Post * Operations on a user resource. */ -public class UpdateUserTest extends AbstractUserManagerTest { +public class UpdateUserTest extends UserManagerTestUtil { String testUserId = null; @Override - protected void tearDown() throws Exception { + public void tearDown() throws Exception { if (testUserId != null) { //remove the test user if it exists. String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserManagerTestUtil.java (from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/AbstractUserManagerTest.java) URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserManagerTestUtil.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserManagerTestUtil.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/AbstractUserManagerTest.java&r1=1538905&r2=1539010&rev=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/AbstractUserManagerTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserManagerTestUtil.java Tue Nov 5 14:34:14 2013 @@ -25,19 +25,21 @@ import javax.servlet.http.HttpServletRes import org.apache.commons.httpclient.Credentials; import org.apache.commons.httpclient.NameValuePair; import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.sling.launchpad.webapp.integrationtest.AbstractAuthenticatedTest; +import org.apache.sling.launchpad.webapp.integrationtest.AuthenticatedTestUtil; /** - * Base class for UserManager tests. + * Base class for UserManager tests. - it's called "Util" now + * as we're moving tests to JUnit4-style which won't extend + * this anymore - but right now some still do. */ -public abstract class AbstractUserManagerTest extends AbstractAuthenticatedTest { +public class UserManagerTestUtil extends AuthenticatedTestUtil { /** * Helper to assist adding a user to a group * @param testUserId the user * @param testGroupId the group */ - protected void addUserToGroup(String testUserId, String testGroupId) throws IOException { + public void addUserToGroup(String testUserId, String testGroupId) throws IOException { String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; List postParams = new ArrayList(); @@ -53,7 +55,7 @@ public abstract class AbstractUserManage * @param testUserId the user * @param testGroupId the group */ - protected void removeUserFromGroup(String testUserId, String testGroupId) throws IOException { + public void removeUserFromGroup(String testUserId, String testGroupId) throws IOException { String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".update.html"; List postParams = new ArrayList(); @@ -68,7 +70,7 @@ public abstract class AbstractUserManage * Add test user to the 'UserAdmin' group * @param testUserId the user */ - protected void addUserToUserAdminGroup(String testUserId) throws IOException { + public void addUserToUserAdminGroup(String testUserId) throws IOException { addUserToGroup(testUserId, "UserAdmin"); } @@ -76,7 +78,7 @@ public abstract class AbstractUserManage * Add test user to the 'GroupAdmin' group * @param testUserId the user */ - protected void addUserToGroupAdminGroup(String testUserId) throws IOException { + public void addUserToGroupAdminGroup(String testUserId) throws IOException { addUserToGroup(testUserId, "GroupAdmin"); } Copied: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java (from r1538905, sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/PrivilegesInfoTest.java) URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java?p2=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java&p1=sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/PrivilegesInfoTest.java&r1=1538905&r2=1539010&rev=1539010&view=diff ============================================================================== --- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/PrivilegesInfoTest.java (original) +++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/userManager/UserPrivilegesInfoTest.java Tue Nov 5 14:34:14 2013 @@ -16,6 +16,8 @@ */ package org.apache.sling.launchpad.webapp.integrationtest.userManager; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; @@ -29,11 +31,14 @@ import org.apache.commons.httpclient.Nam import org.apache.commons.httpclient.UsernamePasswordCredentials; import org.apache.sling.commons.json.JSONException; import org.apache.sling.commons.json.JSONObject; +import org.apache.sling.commons.testing.integration.HttpTest; +import org.apache.sling.commons.testing.junit.categories.JackrabbitOnly; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; -/** - * Tests for the PrivilegesInfo Script Helper - */ -public class PrivilegesInfoTest extends AbstractUserManagerTest { +public class UserPrivilegesInfoTest { String testUserId = null; String testUserId2 = null; @@ -41,21 +46,23 @@ public class PrivilegesInfoTest extends String testFolderUrl = null; Set toDelete = new HashSet(); - @Override - protected void setUp() throws Exception { - super.setUp(); + private final UserManagerTestUtil H = new UserManagerTestUtil(); + + @Before + public void setup() throws Exception { + H.setUp(); // Script for server-side PrivilegeInfo calculations String scriptPath = "/apps/sling/servlet/default"; - testClient.mkdirs(WEBDAV_BASE_URL, scriptPath); - toDelete.add(uploadTestScript(scriptPath, + H.getTestClient().mkdirs(HttpTest.WEBDAV_BASE_URL, scriptPath); + toDelete.add(H.uploadTestScript(scriptPath, "usermanager/privileges-info.json.esp", "privileges-info.json.esp")); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); + @After + public void cleanup() throws Exception { + H.tearDown(); Credentials creds = new UsernamePasswordCredentials("admin", "admin"); @@ -64,29 +71,29 @@ public class PrivilegesInfoTest extends String postUrl = testFolderUrl; List postParams = new ArrayList(); postParams.add(new NameValuePair(":operation", "delete")); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } if (testGroupId != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } if (testUserId != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } if (testUserId2 != null) { //remove the test user if it exists. - String postUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId2 + ".delete.html"; + String postUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId2 + ".delete.html"; List postParams = new ArrayList(); - assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); + H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null); } for(String script : toDelete) { - testClient.delete(script); + H.getTestClient().delete(script); } } @@ -95,25 +102,27 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to add a new user. */ + @Test + @Category(JackrabbitOnly.class) // TODO: fails on Oak public void testCanAddUser() throws JSONException, IOException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); assertEquals(false, jsonObj.getBoolean("canAddUser")); //now add the user to the 'User Admin' group. - addUserToUserAdminGroup(testUserId); + H.addUserToUserAdminGroup(testUserId); //fetch the JSON again - String json2 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -124,25 +133,27 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to add a new group. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanAddGroup() throws IOException, JSONException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); - String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); assertEquals(false, jsonObj.getBoolean("canAddGroup")); //now add the user to the 'Group Admin' group. - addUserToGroupAdminGroup(testUserId); + H.addUserToGroupAdminGroup(testUserId); //fetch the JSON again - String json2 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -153,16 +164,18 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to update the properties of the specified user. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanUpdateUserProperties() throws IOException, JSONException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); //1. verify user can update thier own properties - String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -171,12 +184,12 @@ public class PrivilegesInfoTest extends //2. now try another user - testUserId2 = createTestUser(); + testUserId2 = H.createTestUser(); //fetch the JSON for the test page to verify the settings. Credentials testUser2Creds = new UsernamePasswordCredentials(testUserId2, "testPwd"); - String json2 = getAuthenticatedContent(testUser2Creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -185,10 +198,10 @@ public class PrivilegesInfoTest extends //3. now add the user to the 'User Admin' group. - addUserToUserAdminGroup(testUserId2); + H.addUserToUserAdminGroup(testUserId2); //fetch the JSON again - String json3 = getAuthenticatedContent(testUser2Creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json3 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json3); JSONObject jsonObj3 = new JSONObject(json3); @@ -200,17 +213,19 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to update the properties of the specified group. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanUpdateGroupProperties() throws IOException, JSONException { - testGroupId = createTestGroup(); - testUserId = createTestUser(); + testGroupId = H.createTestGroup(); + testUserId = H.createTestUser(); //1. Verify non admin user can not update group properties - String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -219,10 +234,10 @@ public class PrivilegesInfoTest extends //2. now add the user to the 'Group Admin' group. - addUserToGroupAdminGroup(testUserId); + H.addUserToGroupAdminGroup(testUserId); //fetch the JSON again - String json2 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -234,16 +249,18 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to remove the specified user. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanRemoveUser() throws IOException, JSONException { - testUserId = createTestUser(); + testUserId = H.createTestUser(); //1. verify user can not remove themselves - String getUrl = HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/user/" + testUserId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -252,12 +269,12 @@ public class PrivilegesInfoTest extends //2. now try another user - testUserId2 = createTestUser(); + testUserId2 = H.createTestUser(); //fetch the JSON for the test page to verify the settings. Credentials testUser2Creds = new UsernamePasswordCredentials(testUserId2, "testPwd"); - String json2 = getAuthenticatedContent(testUser2Creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -266,10 +283,10 @@ public class PrivilegesInfoTest extends //3. now add the user to the 'User Admin' group. - addUserToUserAdminGroup(testUserId2); + H.addUserToUserAdminGroup(testUserId2); //fetch the JSON again - String json3 = getAuthenticatedContent(testUser2Creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json3 = H.getAuthenticatedContent(testUser2Creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json3); JSONObject jsonObj3 = new JSONObject(json3); @@ -281,17 +298,19 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to remove the specified group. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanRemoveGroup() throws IOException, JSONException { - testGroupId = createTestGroup(); - testUserId = createTestUser(); + testGroupId = H.createTestGroup(); + testUserId = H.createTestUser(); //1. Verify non admin user can not remove group - String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -300,10 +319,10 @@ public class PrivilegesInfoTest extends //2. now add the user to the 'Group Admin' group. - addUserToGroupAdminGroup(testUserId); + H.addUserToGroupAdminGroup(testUserId); //fetch the JSON again - String json2 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -315,17 +334,19 @@ public class PrivilegesInfoTest extends * Checks whether the current user has been granted privileges * to update the membership of the specified group. */ + @Category(JackrabbitOnly.class) // TODO: fails on Oak + @Test public void testCanUpdateGroupMembers() throws IOException, JSONException { - testGroupId = createTestGroup(); - testUserId = createTestUser(); + testGroupId = H.createTestGroup(); + testUserId = H.createTestUser(); //1. Verify non admin user can not update group membership - String getUrl = HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; + String getUrl = HttpTest.HTTP_BASE_URL + "/system/userManager/group/" + testGroupId + ".privileges-info.json"; //fetch the JSON for the test page to verify the settings. Credentials testUserCreds = new UsernamePasswordCredentials(testUserId, "testPwd"); - String json = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json); JSONObject jsonObj = new JSONObject(json); @@ -334,10 +355,10 @@ public class PrivilegesInfoTest extends //2. now add the user to the 'Group Admin' group. - addUserToGroupAdminGroup(testUserId); + H.addUserToGroupAdminGroup(testUserId); //fetch the JSON again - String json2 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json2 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json2); JSONObject jsonObj2 = new JSONObject(json2); @@ -346,10 +367,10 @@ public class PrivilegesInfoTest extends //3. remove user from the 'Group Admin' group - removeUserFromGroup(testUserId, "GroupAdmin"); + H.removeUserFromGroup(testUserId, "GroupAdmin"); //fetch the JSON again - String json3 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json3 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json3); JSONObject jsonObj3 = new JSONObject(json3); @@ -358,10 +379,10 @@ public class PrivilegesInfoTest extends //4. add user to the 'User Admin' group - addUserToUserAdminGroup(testUserId); + H.addUserToUserAdminGroup(testUserId); //fetch the JSON again - String json4 = getAuthenticatedContent(testUserCreds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); + String json4 = H.getAuthenticatedContent(testUserCreds, getUrl, HttpTest.CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK); assertNotNull(json4); JSONObject jsonObj4 = new JSONObject(json4);