You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/05/07 10:31:24 UTC

svn commit: r772547 - /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java

Author: angela
Date: Thu May  7 08:31:23 2009
New Revision: 772547

URL: http://svn.apache.org/viewvc?rev=772547&view=rev
Log:
JCR-1588: JSR 283: Access Control

- test case for aggregate privileges covering Privilege. getAggregatePrivileges() and .getDeclaredAggregatePrivileges()

Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java?rev=772547&r1=772546&r2=772547&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java (original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/security/AccessControlDiscoveryTest.java Thu May  7 08:31:23 2009
@@ -104,8 +104,8 @@
     public void testAllPrivilegeContainsAll() throws RepositoryException, NotExecutableException {
         Privilege[] supported = acMgr.getSupportedPrivileges(testRootNode.getPath());
 
-        Set allSet = new HashSet();
         Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
+        Set allSet = new HashSet();
         allSet.addAll(Arrays.asList(all.getAggregatePrivileges()));
 
         String msg = "The all privilege must also contain ";
@@ -120,6 +120,12 @@
         }
     }
 
+    /**
+     * Test the jcr:all privilege.
+     * 
+     * @throws RepositoryException
+     * @throws NotExecutableException
+     */
     public void testAllPrivilege() throws RepositoryException, NotExecutableException {
         Privilege all = acMgr.privilegeFromName(Privilege.JCR_ALL);
         assertFalse("All privilege must be not be abstract.", all.isAbstract());
@@ -129,6 +135,7 @@
     }
 
     /**
+     * Test the jcr:write privilege.
      *
      * @throws RepositoryException If an error occurs.
      * @throws NotExecutableException If the test cannot be executed.
@@ -141,6 +148,35 @@
     }
 
     /**
+     * Test some simple characteristics of the known aggregate privileges (jcr:write and jcr:all).
+     *
+     * @throws RepositoryException
+     */
+    public void testAggregregatePrivileges() throws RepositoryException {
+        List l = new ArrayList();
+        l.add(getJCRName(Privilege.JCR_WRITE, superuser));
+        l.add(getJCRName(Privilege.JCR_ALL, superuser));
+
+        for (Iterator it = l.iterator(); it.hasNext();) {
+            String privName = it.next().toString();
+            Privilege p = acMgr.privilegeFromName(privName);
+
+            assertTrue("write and all must always be aggregate privileges.", p.isAggregate());
+            Privilege[] aggregatedPrvs = p.getAggregatePrivileges();
+            Privilege[] declaredPrvs = p.getDeclaredAggregatePrivileges();
+
+            assertNotNull("An aggregate privilege must return the aggregated privileges", aggregatedPrvs);
+            assertTrue("An aggregate privilege must return the aggregated privileges", aggregatedPrvs.length > 0);
+
+            assertNotNull("An aggregate privilege must return the declared aggregated privileges", declaredPrvs);
+            assertTrue("An aggregate privilege must return the declared aggregated privileges", declaredPrvs.length > 0);
+
+            assertTrue("The may be at least the same amount of declared aggregated privileges.", aggregatedPrvs.length >= declaredPrvs.length);
+        }
+
+    }
+    
+    /**
      * Tests if the privilege name is treated as JCR Name and consequently
      * reflects changes made to the namespace prefix.
      *