jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1483298 - in /jackrabbit/oak/trunk/oak-jcr: pom.xml src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java
Date Thu, 16 May 2013 11:19:17 GMT
Author: angela
Date: Thu May 16 11:19:17 2013
New Revision: 1483298

URL: http://svn.apache.org/r1483298
Log:
OAK-51 : Access Control Management (backwards compatible import that removes existing entries
-> fix test, which was commented in jr2)

Modified:
    jackrabbit/oak/trunk/oak-jcr/pom.xml
    jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java

Modified: jackrabbit/oak/trunk/oak-jcr/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/pom.xml?rev=1483298&r1=1483297&r2=1483298&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-jcr/pom.xml Thu May 16 11:19:17 2013
@@ -290,8 +290,6 @@
       org.apache.jackrabbit.oak.jcr.security.authorization.WriteTest#testRemove7    <!--
OAK-781 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.WriteTest#testRemoveIfReadingParentIsDenied
     <!-- OAK-813 -->
 
-      org.apache.jackrabbit.oak.jcr.security.authorization.AccessControlImporterTest#testImportPolicyExists
<!-- OAK-414 -->
-
       org.apache.jackrabbit.oak.jcr.security.authorization.AccessControlManagementTest#testRemoveMixin
             <!-- OAK-767 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.NodeTypeManagementTest#testRemoveMixin
                  <!-- OAK-767 -->
       org.apache.jackrabbit.oak.jcr.security.authorization.NodeTypeManagementTest#testRemoveMixinWithoutPermission
 <!-- OAK-767 -->

Modified: jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java?rev=1483298&r1=1483297&r2=1483298&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java
(original)
+++ jackrabbit/oak/trunk/oak-jcr/src/test/java/org/apache/jackrabbit/oak/jcr/security/authorization/AccessControlImporterTest.java
Thu May 16 11:19:17 2013
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.oak.jcr.se
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.security.Principal;
 import java.util.Arrays;
 import java.util.List;
 import javax.jcr.ImportUUIDBehavior;
@@ -31,12 +32,10 @@ import javax.jcr.security.AccessControlP
 import javax.jcr.security.AccessControlPolicyIterator;
 import javax.jcr.security.Privilege;
 
+import org.apache.jackrabbit.api.JackrabbitSession;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlEntry;
 import org.apache.jackrabbit.api.security.JackrabbitAccessControlList;
-import org.apache.jackrabbit.oak.jcr.SessionImpl;
 import org.apache.jackrabbit.test.AbstractJCRTest;
-import org.junit.Ignore;
-import org.xml.sax.SAXException;
 
 public class AccessControlImporterTest extends AbstractJCRTest {
 
@@ -343,12 +342,10 @@ public class AccessControlImporterTest e
 
     /**
      * Imports a resource-based ACL containing a single entry for a policy that
-     * already exists.
-     *
-     * @throws Exception
+     * already exists: expected outcome its that the existing ACE is replaced.
      */
-    @Ignore("OAK-414") // FIXME
     public void testImportPolicyExists() throws Exception {
+        Principal everyone = ((JackrabbitSession) superuser).getPrincipalManager().getEveryone();
         Node target = testRootNode;
         target = target.addNode("test", "test:sameNameSibsFalseChildNodeDefinition");
         AccessControlManager acMgr = superuser.getAccessControlManager();
@@ -356,17 +353,15 @@ public class AccessControlImporterTest e
             AccessControlPolicy policy = it.nextAccessControlPolicy();
             if (policy instanceof AccessControlList) {
                 Privilege[] privs = new Privilege[] {acMgr.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT)};
-                ((AccessControlList) policy).addAccessControlEntry(((SessionImpl)superuser).getPrincipalManager().getEveryone(),
privs);
+                ((AccessControlList) policy).addAccessControlEntry(everyone, privs);
                 acMgr.setPolicy(target.getPath(), policy);
             }
         }
 
         try {
-
             doImport(target.getPath(), XML_POLICY_TREE_2);
 
             AccessControlPolicy[] policies = acMgr.getPolicies(target.getPath());
-
             assertEquals(1, policies.length);
             assertTrue(policies[0] instanceof JackrabbitAccessControlList);
 
@@ -374,18 +369,14 @@ public class AccessControlImporterTest e
             assertEquals(1, entries.length);
 
             AccessControlEntry entry = entries[0];
-            assertEquals("everyone", entry.getPrincipal().getName());
+            assertEquals(everyone.getName(), entry.getPrincipal().getName());
             List<Privilege> privs = Arrays.asList(entry.getPrivileges());
-            assertEquals(2, privs.size());
-            assertTrue(privs.contains(acMgr.privilegeFromName(Privilege.JCR_WRITE)) &&
-                    privs.contains(acMgr.privilegeFromName(Privilege.JCR_LOCK_MANAGEMENT)));
-
+            assertEquals(1, privs.size());
             assertEquals(acMgr.privilegeFromName(Privilege.JCR_WRITE), entry.getPrivileges()[0]);
 
             if(entry instanceof JackrabbitAccessControlEntry) {
                 assertTrue(((JackrabbitAccessControlEntry) entry).isAllow());
             }
-
         } finally {
             superuser.refresh(false);
         }
@@ -492,7 +483,7 @@ public class AccessControlImporterTest e
         }
     }
 
-    private void doImport(String parentPath, String xml) throws IOException, SAXException,
RepositoryException {
+    private void doImport(String parentPath, String xml) throws IOException, RepositoryException
{
         InputStream in = new ByteArrayInputStream(xml.getBytes("UTF-8"));
         superuser.importXML(parentPath, in, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW);
     }



Mime
View raw message