jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1470469 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java
Date Mon, 22 Apr 2013 12:07:56 GMT
Author: angela
Date: Mon Apr 22 12:07:56 2013
New Revision: 1470469

URL: http://svn.apache.org/r1470469
Log:
OAK-51 : Access Control Management (mark test that shows OAK-787 as ignored)

Modified:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java?rev=1470469&r1=1470468&r2=1470469&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/security/authorization/AccessControlManagerImplTest.java
Mon Apr 22 12:07:56 2013
@@ -37,6 +37,7 @@ import javax.jcr.security.AccessControlE
 import javax.jcr.security.AccessControlManager;
 import javax.jcr.security.AccessControlPolicy;
 import javax.jcr.security.AccessControlPolicyIterator;
+import javax.jcr.security.NamedAccessControlPolicy;
 import javax.jcr.security.Privilege;
 
 import com.google.common.collect.ImmutableMap;
@@ -63,6 +64,7 @@ import org.apache.jackrabbit.oak.util.No
 import org.apache.jackrabbit.oak.util.TreeUtil;
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import static org.junit.Assert.assertArrayEquals;
@@ -638,10 +640,7 @@ public class AccessControlManagerImplTes
 
     }
 
-    /**
-     * // TODO review again
-     * @since OAK 1.0 : access to privileges needs read access to the corresponding tree.
-     */
+    @Ignore("OAK-787") // FIXME
     @Test
     public void testTestSessionGetPrivileges() throws Exception {
         setupPolicy(testPath);
@@ -650,42 +649,14 @@ public class AccessControlManagerImplTes
         AccessControlManagerImpl testAcMgr = getTestAccessControlManager();
         Set<Principal> testPrincipals = getPrincipals(getTestRoot().getContentSession());
 
-        // TODO: check again...
-        try {
-            testAcMgr.getPrivileges(testPath);
-            fail("no read access to the privilege store.");
-        } catch (AccessControlException e) {
-            // success
-        }
-        try {
-            getTestAccessControlManager().getPrivileges(testPath, testPrincipals);
-            fail("no read access to the privilege store.");
-        } catch (AccessControlException e) {
-            // success
-        }
-
-        // ensure readability of the privileges
-        try {
-            setupPolicy("/jcr:system");
-            root.commit();
+        assertArrayEquals(new Privilege[0], testAcMgr.getPrivileges(null));
+        assertArrayEquals(new Privilege[0], testAcMgr.getPrivileges(null, testPrincipals));
 
-            getTestRoot().refresh();
+        Privilege[] privs = testAcMgr.getPrivileges(testPath);
+        assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs));
 
-            assertArrayEquals(new Privilege[0], testAcMgr.getPrivileges(null));
-            assertArrayEquals(new Privilege[0], testAcMgr.getPrivileges(null, testPrincipals));
-
-            Privilege[] privs = testAcMgr.getPrivileges(testPath);
-            assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs));
-
-            privs = testAcMgr.getPrivileges(testPath, testPrincipals);
-            assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs));
-
-        } finally {
-            for (AccessControlPolicy policy : acMgr.getPolicies("/jcr:system")) {
-                acMgr.removePolicy("/jcr:system", policy);
-            }
-            root.commit();
-        }
+        privs = testAcMgr.getPrivileges(testPath, testPrincipals);
+        assertEquals(ImmutableSet.copyOf(testPrivileges), ImmutableSet.copyOf(privs));
 
         // but for 'admin' the test-session doesn't have sufficient privileges
         try {
@@ -918,14 +889,14 @@ public class AccessControlManagerImplTes
 
         AccessControlPolicy[] policies = acMgr.getPolicies(path);
         assertNotNull(policies);
-        assertEquals(0, policies.length);
+        assertEquals(1, policies.length);
 
         acMgr.setPolicy(null, acMgr.getApplicablePolicies(path).nextAccessControlPolicy());
         assertFalse(acMgr.getApplicablePolicies(path).hasNext());
 
         policies = acMgr.getPolicies(path);
         assertNotNull(policies);
-        assertEquals(1, policies.length);
+        assertEquals(2, policies.length);
 
         assertTrue(policies[0] instanceof ACL);
         ACL acl = (ACL) policies[0];
@@ -934,8 +905,11 @@ public class AccessControlManagerImplTes
         assertNull(acl.getOakPath());
         assertFalse(acMgr.getApplicablePolicies(path).hasNext());
 
+        assertTrue(policies[1] instanceof NamedAccessControlPolicy);
+
         acMgr.removePolicy(path, acl);
-        assertEquals(0, acMgr.getPolicies(path).length);
+        assertEquals(1, acMgr.getPolicies(path).length);
+        assertTrue(acMgr.getPolicies(path)[0] instanceof NamedAccessControlPolicy);
         assertTrue(acMgr.getApplicablePolicies(path).hasNext());
     }
 
@@ -1063,7 +1037,7 @@ public class AccessControlManagerImplTes
 
         Root root2 = adminSession.getLatestRoot();
         AccessControlPolicy[] policies = getAccessControlManager(root2).getPolicies((String)
null);
-        assertEquals(1, policies.length);
+        assertEquals(2, policies.length);
         assertArrayEquals(acl.getAccessControlEntries(), ((ACL) policies[0]).getAccessControlEntries());
     }
 
@@ -1254,7 +1228,7 @@ public class AccessControlManagerImplTes
 
         acMgr.removePolicy(null, acl);
 
-        assertEquals(0, acMgr.getPolicies((String) null).length);
+        assertEquals(1, acMgr.getPolicies((String) null).length);
         assertTrue(acMgr.getApplicablePolicies((String) null).hasNext());
     }
 



Mime
View raw message