incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1539021 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java
Date Tue, 05 Nov 2013 15:07:18 GMT
Author: bdelacretaz
Date: Tue Nov  5 15:07:17 2013
New Revision: 1539021

URL: http://svn.apache.org/r1539021
Log:
SLING-3225 - Use JackrabbitOnly category to disable tests that fail on Oak

Modified:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/accessManager/ModifyAceTest.java

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=1539021&r1=1539020&r2=1539021&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 15:07:17 2013
@@ -16,6 +16,11 @@
  */
 package org.apache.sling.launchpad.webapp.integrationtest.accessManager;
 
+import static org.junit.Assert.assertEquals;
+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;
 import java.util.HashSet;
@@ -30,20 +35,32 @@ import org.apache.commons.httpclient.Use
 import org.apache.sling.commons.json.JSONArray;
 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 'modifyAce' Sling Post Operation
  */
-public class ModifyAceTest extends AccessManagerTestUtil {
+public class ModifyAceTest {
 
 	String testUserId = null;
 	String testUserId2 = null;
 	String testGroupId = null;
 	String testFolderUrl = null;
 	
-	@Override
-	public void tearDown() throws Exception {
-		super.tearDown();
+	private final AccessManagerTestUtil H = new AccessManagerTestUtil();  
+	
+	@Before
+    public void setup() throws Exception {
+	    H.setUp();
+	}
+	@After
+	public void cleanup() throws Exception {
+		H.tearDown();
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
 
@@ -52,32 +69,33 @@ public class ModifyAceTest extends Acces
 			String postUrl = testFolderUrl;
 			List<NameValuePair> postParams = new ArrayList<NameValuePair>();
 			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<NameValuePair> postParams = new ArrayList<NameValuePair>();
-			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<NameValuePair> postParams = new ArrayList<NameValuePair>();
-			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<NameValuePair> postParams = new ArrayList<NameValuePair>();
-			assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+			H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		}
 	}
 
+	@Test 
 	public void testModifyAceForUser() throws IOException, JSONException {
-		testUserId = createTestUser();
+		testUserId = H.createTestUser();
 		
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -88,13 +106,13 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "bogus")); //invalid
value should be ignored.
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		JSONObject jsonObject = new JSONObject(json);
 		assertEquals(1, jsonObject.length());
@@ -119,10 +137,11 @@ public class ModifyAceTest extends Acces
 		assertEquals("jcr:write", deniedArray.getString(0));
 	}
 
+	@Test 
 	public void testModifyAceForGroup() throws IOException, JSONException {
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -133,13 +152,13 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "bogus")); //invalid
value should be ignored.
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		JSONObject jsonObject = new JSONObject(json);
 		assertEquals(1, jsonObject.length());
@@ -167,9 +186,10 @@ public class ModifyAceTest extends Acces
 	 * Test for SLING-997, preserve privileges that were not posted with the modifyAce 
 	 * request.
 	 */
+	@Test 
 	public void testMergeAceForUser() throws IOException, JSONException {
-		testUserId = createTestUser();
-		testFolderUrl = createTestFolder();
+		testUserId = H.createTestUser();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -183,12 +203,12 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:removeChildNodes", "denied"));
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		JSONObject jsonObject = new JSONObject(json);
 		assertEquals(1, jsonObject.length());
@@ -209,9 +229,9 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:readAccessControl");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:addChildNodes");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:readAccessControl");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:addChildNodes");
 
 		JSONArray deniedArray = aceObject.optJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -220,8 +240,8 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames, true, "jcr:modifyAccessControl");
-		assertPrivilege(deniedPrivilegeNames, true, "jcr:removeChildNodes");
+		H.assertPrivilege(deniedPrivilegeNames, true, "jcr:modifyAccessControl");
+		H.assertPrivilege(deniedPrivilegeNames, true, "jcr:removeChildNodes");
 		
 		
 		
@@ -236,11 +256,11 @@ public class ModifyAceTest extends Acces
 		postParams2.add(new NameValuePair("privilege@jcr:removeChildNodes", "none")); //clear the
existing privilege
 		postParams2.add(new NameValuePair("privilege@jcr:removeNode", "denied")); //deny a new
privilege
 		
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
-		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json2 = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 		JSONObject jsonObject2 = new JSONObject(json2);
 		assertEquals(1, jsonObject2.length());
@@ -258,9 +278,9 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:addChildNodes");
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:addChildNodes");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -269,8 +289,8 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:modifyAccessControl");
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:modifyAccessControl");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
 	}
 
 	
@@ -278,9 +298,10 @@ public class ModifyAceTest extends Acces
 	 * Test for SLING-997, preserve privileges that were not posted with the modifyAce 
 	 * request.
 	 */
+	@Test 
 	public void testMergeAceForUserSplitAggregatePrincipal() throws IOException, JSONException
{
-		testUserId = createTestUser();
-		testFolderUrl = createTestFolder();
+		testUserId = H.createTestUser();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -291,12 +312,12 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:write", "denied"));
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
 		JSONObject jsonObject = new JSONObject(json);
@@ -314,7 +335,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
 
 		JSONArray deniedArray = aceObject.optJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -323,7 +344,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames, true, "jcr:write");
+		H.assertPrivilege(deniedPrivilegeNames, true, "jcr:write");
 		
 		
 		
@@ -335,11 +356,11 @@ public class ModifyAceTest extends Acces
 		//jcr:write is not posted, but one of the aggregate privileges is now granted, so the aggregate
priviledge should be disagreaged into
 		//  the remaining denied privileges in the denied ACE
 		
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
-		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json2 = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 		
 		JSONObject jsonObject2 = new JSONObject(json2);
@@ -357,8 +378,8 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:modifyProperties");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -367,20 +388,21 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames2, false, "jcr:write");
+		H.assertPrivilege(deniedPrivilegeNames2, false, "jcr:write");
 		//only the remaining privileges from the disaggregated jcr:write collection should remain.
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:addChildNodes");
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeChildNodes");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:addChildNodes");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeNode");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:removeChildNodes");
 	}
 
 	/**
 	 * Test for SLING-997, preserve privileges that were not posted with the modifyAce 
 	 * request.
 	 */
+	@Test 
 	public void testMergeAceForUserCombineAggregatePrivilege() throws IOException, JSONException
{
-		testUserId = createTestUser();
-		testFolderUrl = createTestFolder();
+		testUserId = H.createTestUser();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -391,12 +413,12 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:removeNode", "denied"));
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
 		JSONObject jsonObject = new JSONObject(json);
@@ -414,7 +436,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
 
 		JSONArray deniedArray = aceObject.getJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -423,7 +445,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray.length(); i++) {
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames, true, "jcr:removeNode");
+		H.assertPrivilege(deniedPrivilegeNames, true, "jcr:removeNode");
 		
 		
 		
@@ -436,11 +458,11 @@ public class ModifyAceTest extends Acces
 		//existing part.
 		postParams2.add(new NameValuePair("privilege@jcr:write", "denied")); //add a new privilege
 		
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
-		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json2 = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 		
 		JSONObject jsonObject2 = new JSONObject(json2);
@@ -458,7 +480,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:read");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -467,7 +489,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:write");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:write");
 	}
 
 	
@@ -475,9 +497,10 @@ public class ModifyAceTest extends Acces
 	 * Test ACE update with a deny privilege for an ACE that already contains
 	 * a grant privilege 
 	 */
+	@Test 
 	public void testMergeAceForUserDenyPrivilegeAfterGrantPrivilege() throws IOException, JSONException
{
-		testUserId = createTestUser();
-		testFolderUrl = createTestFolder();
+		testUserId = H.createTestUser();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.html";
 
@@ -487,12 +510,12 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:write", "granted"));
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 		
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
 		JSONObject jsonObject = new JSONObject(json);
@@ -510,7 +533,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
 
 		assertFalse(aceObject.has("denied"));
 		
@@ -524,11 +547,11 @@ public class ModifyAceTest extends Acces
 		//existing ACE.
 		postParams2.add(new NameValuePair("privilege@jcr:nodeTypeManagement", "denied")); //add
a new privilege
 		
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams2,
null);
 		
 		
 		//fetch the JSON for the acl to verify the settings.
-		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json2 = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 
 		JSONObject jsonObject2 = new JSONObject(json2);
@@ -546,7 +569,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray2.length(); i++) {
 			grantedPrivilegeNames2.add(grantedArray2.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames2, true, "jcr:write");
+		H.assertPrivilege(grantedPrivilegeNames2, true, "jcr:write");
 
 		JSONArray deniedArray2 = aceObject2.optJSONArray("denied");
 		assertNotNull(deniedArray2);
@@ -555,7 +578,7 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < deniedArray2.length(); i++) {
 			deniedPrivilegeNames2.add(deniedArray2.getString(i));
 		}
-		assertPrivilege(deniedPrivilegeNames2, true, "jcr:nodeTypeManagement");
+		H.assertPrivilege(deniedPrivilegeNames2, true, "jcr:nodeTypeManagement");
 	}
 
 
@@ -564,10 +587,11 @@ public class ModifyAceTest extends Acces
 	 * Test to verify adding an ACE in the first position of 
 	 * the ACL
 	 */
+	@Test 
 	public void testAddAceOrderByFirst() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "first");
 
@@ -575,7 +599,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
 		JSONObject jsonObject = new JSONObject(json);
@@ -595,10 +619,11 @@ public class ModifyAceTest extends Acces
 	 * Test to verify adding an ACE at the end 
 	 * the ACL
 	 */
+	@Test 
 	public void testAddAceOrderByLast() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "last");
 
@@ -606,7 +631,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
 		JSONObject jsonObject = new JSONObject(json);
@@ -627,10 +652,11 @@ public class ModifyAceTest extends Acces
 	 * Test to verify adding an ACE before an existing ACE 
 	 * the ACL
 	 */
+	@Test 
 	public void testAddAceOrderByBefore() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "before " + testUserId);
 
@@ -638,7 +664,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
 		
@@ -661,10 +687,11 @@ public class ModifyAceTest extends Acces
 	 * Test to verify adding an ACE after an existing ACE 
 	 * the ACL
 	 */
+	@Test 
 	public void testAddAceOrderByAfter() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "after " + testUserId);
 
@@ -672,7 +699,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
                 JSONObject jsonObject = new JSONObject(json);
@@ -693,17 +720,18 @@ public class ModifyAceTest extends Acces
 	 * Test to verify adding an ACE at a specific index inside 
 	 * the ACL
 	 */
+	@Test 
 	public void testAddAceOrderByNumeric() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "0");
 
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 
 		
@@ -723,10 +751,10 @@ public class ModifyAceTest extends Acces
 
 
 		//add another principal between the testGroupId and testUserId
-		testUserId2 = createTestUser();
+		testUserId2 = H.createTestUser();
 		addOrUpdateAce(testFolderUrl, testUserId2, true, "1");
 
-		String json2 = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json2 = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json2);
 
                 JSONObject jsonObject2 = new JSONObject(json2);
@@ -753,10 +781,11 @@ public class ModifyAceTest extends Acces
 	 * Test to make sure modifying an existing ace without changing the order 
 	 * leaves the ACE in the same position in the ACL
 	 */
+	@Test 
 	public void testUpdateAcePreservePosition() throws IOException, JSONException {
 		createAceOrderTestFolderWithOneAce();
 		
-		testGroupId = createTestGroup();
+		testGroupId = H.createTestGroup();
 
 		addOrUpdateAce(testFolderUrl, testGroupId, true, "first");
 
@@ -768,7 +797,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
                 JSONObject jsonObject = new JSONObject(json);
@@ -790,9 +819,9 @@ public class ModifyAceTest extends Acces
 	 * Helper to create a test folder with a single ACE pre-created
 	 */
 	private void createAceOrderTestFolderWithOneAce() throws IOException, JSONException {
-		testUserId = createTestUser();
+		testUserId = H.createTestUser();
 		
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 
 		addOrUpdateAce(testFolderUrl, testUserId, true, null);
 
@@ -800,7 +829,7 @@ public class ModifyAceTest extends Acces
 		String getUrl = testFolderUrl + ".acl.json";
 
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
                 JSONObject jsonObject = new JSONObject(json);
@@ -829,16 +858,17 @@ public class ModifyAceTest extends Acces
 		}
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams, null);
+		H.assertAuthenticatedPostStatus(creds, postUrl, HttpServletResponse.SC_OK, postParams,
null);
 	}
 	
 	/**
 	 * Test for SLING-1677
 	 */
+	@Test 
 	public void testModifyAceResponseAsJSON() throws IOException, JSONException {
-		testUserId = createTestUser();
+		testUserId = H.createTestUser();
 		
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.json";
 
@@ -849,7 +879,7 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "bogus")); //invalid
value should be ignored.
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		String json = getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams,
HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON,
postParams, HttpServletResponse.SC_OK);
 
         //make sure the json response can be parsed as a JSON object
         JSONObject jsonObject = new JSONObject(json);
@@ -860,10 +890,11 @@ public class ModifyAceTest extends Acces
 	/**
 	 * Test for SLING-3010
 	 */
+	@Test 
 	public void testMergeAceForUserGrantNestedAggregatePrivilegeAfterDenySuperAggregatePrivilege()
throws IOException, JSONException {
-		testUserId = createTestUser();
+		testUserId = H.createTestUser();
 		
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.json";
 
@@ -876,7 +907,7 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@rep:write", "denied")); 
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		/*String json = */getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams,
HttpServletResponse.SC_OK);
+		/*String json = */H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON,
postParams, HttpServletResponse.SC_OK);
 
 		
         //2. now grant the jcr:write subset from the rep:write aggregate privilege
@@ -887,13 +918,13 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:modifyAccessControl", "granted")); 
 		postParams.add(new NameValuePair("privilege@jcr:write", "granted")); //sub-aggregate of
rep:write  
 		
-		/*String json = */getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams,
HttpServletResponse.SC_OK);
+		/*String json = */H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON,
postParams, HttpServletResponse.SC_OK);
 		
 		//3. verify that the acl has the correct values
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
 		JSONObject jsonObject = new JSONObject(json);
@@ -911,10 +942,10 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:write");
 
 		JSONArray deniedArray = aceObject.getJSONArray("denied");
 		assertNotNull(deniedArray);
@@ -924,16 +955,18 @@ public class ModifyAceTest extends Acces
 			deniedPrivilegeNames.add(deniedArray.getString(i));
 		}
 		//the leftovers from the denied rep:write that were not granted with jcr:write
-		assertPrivilege(deniedPrivilegeNames, true, "jcr:nodeTypeManagement"); 
+		H.assertPrivilege(deniedPrivilegeNames, true, "jcr:nodeTypeManagement"); 
 	}
 
 	/**
 	 * Test for SLING-3010
 	 */
+	@Test 
+    @Category(JackrabbitOnly.class) // TODO: fails on Oak
 	public void testMergeAceForUserGrantAggregatePrivilegePartsAfterDenyAggregatePrivilege()
throws IOException, JSONException {
-		testUserId = createTestUser();
+		testUserId = H.createTestUser();
 		
-		testFolderUrl = createTestFolder();
+		testFolderUrl = H.createTestFolder();
 		
         String postUrl = testFolderUrl + ".modifyAce.json";
 
@@ -946,7 +979,7 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@rep:write", "denied")); 
 		
 		Credentials creds = new UsernamePasswordCredentials("admin", "admin");
-		/*String json = */getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams,
HttpServletResponse.SC_OK);
+		/*String json = */H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON,
postParams, HttpServletResponse.SC_OK);
 
         //2. now grant the all the privileges contained in the rep:write privilege
 		postParams = new ArrayList<NameValuePair>();
@@ -957,13 +990,13 @@ public class ModifyAceTest extends Acces
 		postParams.add(new NameValuePair("privilege@jcr:nodeTypeManagement", "granted")); //sub-privilege
of rep:write  
 		postParams.add(new NameValuePair("privilege@jcr:write", "granted")); //sub-aggregate of
rep:write  
 		
-		/*String json = */getAuthenticatedPostContent(creds, postUrl, CONTENT_TYPE_JSON, postParams,
HttpServletResponse.SC_OK);
+		/*String json = */H.getAuthenticatedPostContent(creds, postUrl, HttpTest.CONTENT_TYPE_JSON,
postParams, HttpServletResponse.SC_OK);
 		
 		//3. verify that the acl has the correct values
 		//fetch the JSON for the acl to verify the settings.
 		String getUrl = testFolderUrl + ".acl.json";
 
-		String json = getAuthenticatedContent(creds, getUrl, CONTENT_TYPE_JSON, null, HttpServletResponse.SC_OK);
+		String json = H.getAuthenticatedContent(creds, getUrl, HttpTest.CONTENT_TYPE_JSON, null,
HttpServletResponse.SC_OK);
 		assertNotNull(json);
 		
 		JSONObject jsonObject = new JSONObject(json);
@@ -980,10 +1013,10 @@ public class ModifyAceTest extends Acces
 		for (int i=0; i < grantedArray.length(); i++) {
 			grantedPrivilegeNames.add(grantedArray.getString(i));
 		}
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
-		assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
-		assertPrivilege(grantedPrivilegeNames, true, "rep:write"); //jcr:nodeTypeManagement + jcr:write
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:versionManagement");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:read");
+		H.assertPrivilege(grantedPrivilegeNames, true, "jcr:modifyAccessControl");
+		H.assertPrivilege(grantedPrivilegeNames, true, "rep:write"); //jcr:nodeTypeManagement +
jcr:write
         assertEquals("Expecting the correct number of privileges in " + grantedPrivilegeNames,
4, grantedPrivilegeNames.size());
 
 		//should be nothing left in the denied set.



Mime
View raw message