jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1570754 - in /jackrabbit/commons/filevault/trunk/vault-core/src: main/java/org/apache/jackrabbit/vault/fs/impl/io/ test/java/org/apache/jackrabbit/vault/packaging/integration/ test/resources/org/apache/jackrabbit/vault/packaging/integratio...
Date Fri, 21 Feb 2014 23:59:22 GMT
Author: tripod
Date: Fri Feb 21 23:59:21 2014
New Revision: 1570754

URL: http://svn.apache.org/r1570754
Log:
JCRVLT-37 Regression: Order of ACE entries is not correct

Added:
    jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/mode_ac_test_e.zip
Modified:
    jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
    jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestACLAndMerge.java

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java?rev=1570754&r1=1570753&r2=1570754&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/main/java/org/apache/jackrabbit/vault/fs/impl/io/JackrabbitACLImporter.java
Fri Feb 21 23:59:21 2014
@@ -20,6 +20,7 @@ import java.security.Principal;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -65,7 +66,7 @@ public class JackrabbitACLImporter imple
 
     private final String accessControlledPath;
 
-    private Map<String, List<ACE>> aceMap = new HashMap<String, List<ACE>>();
+    private Map<String, List<ACE>> aceMap = new LinkedHashMap<String, List<ACE>>();
 
     private ACE currentACE;
 

Modified: jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestACLAndMerge.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestACLAndMerge.java?rev=1570754&r1=1570753&r2=1570754&view=diff
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestACLAndMerge.java
(original)
+++ jackrabbit/commons/filevault/trunk/vault-core/src/test/java/org/apache/jackrabbit/vault/packaging/integration/TestACLAndMerge.java
Fri Feb 21 23:59:21 2014
@@ -19,6 +19,7 @@ package org.apache.jackrabbit.vault.pack
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -40,9 +41,9 @@ import org.apache.jackrabbit.vault.fs.io
 import org.apache.jackrabbit.vault.packaging.JcrPackage;
 import org.apache.jackrabbit.vault.packaging.PackageException;
 import org.junit.Assume;
-import org.junit.Ignore;
 import org.junit.Test;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
@@ -250,6 +251,53 @@ public class TestACLAndMerge extends Int
     }
 
     /**
+     * Installs a package with 3 ACLs and checks if the order of the entries is still correct.
+     */
+    @Test
+    public void testACOrderOverwrite() throws Exception {
+        assertNodeMissing("/testroot");
+        doOrderTest(AccessControlHandling.OVERWRITE);
+    }
+
+    /**
+     * Installs a package with 3 ACLs and checks if the order of the entries is still correct.
+     */
+    @Test
+    public void testACOrderMerge() throws Exception {
+        assertNodeMissing("/testroot");
+        doOrderTest(AccessControlHandling.OVERWRITE);
+        doOrderTest(AccessControlHandling.MERGE);
+    }
+
+    /**
+     * Installs a package with 3 ACLs and checks if the order of the entries is still correct.
+     */
+    @Test
+    public void testACOrderMergePreserve() throws Exception {
+        assertNodeMissing("/testroot");
+        doOrderTest(AccessControlHandling.OVERWRITE);
+        doOrderTest(AccessControlHandling.MERGE_PRESERVE);
+    }
+
+    private void doOrderTest(AccessControlHandling ac) throws Exception {
+        JcrPackage pack = packMgr.upload(getStream("testpackages/mode_ac_test_e.zip"), true);
+        assertNotNull(pack);
+        ImportOptions opts = getDefaultOptions();
+        opts.setAccessControlHandling(ac);
+        pack.install(opts);
+
+        // test if nodes and ACLs of first package exist
+        assertNodeExists("/testroot/node_e");
+        int idx0 = hasPermission("/testroot/secured", false, new String[]{"jcr:all"}, "everyone",
Collections.<String, String[]>emptyMap());
+        int idx1 = hasPermission("/testroot/secured", true, new String[]{"jcr:all"}, "testuser",
Collections.<String, String[]>emptyMap());
+        int idx2 = hasPermission("/testroot/secured", true, new String[]{"jcr:all"}, "testuser1",
Collections.<String, String[]>emptyMap());
+
+        assertTrue("All ACEs must exist", idx0 >= 0 && idx1 >= 0 &&
idx2 >= 0);
+        String result = String.format("%d < %d < %d", idx0, idx1, idx2);
+        assertEquals("ACE order ", "0 < 1 < 2", result);
+    }
+
+    /**
      * Installs a package with oak ACL content.
      */
     @Test
@@ -269,7 +317,7 @@ public class TestACLAndMerge extends Int
         restrictions.put("rep:prefixes", new String[]{"rep", "granite"});
         assertTrue(
                 "expected permission missing",
-                hasPermission("/testroot/secured", true, new String[]{"jcr:all"}, "everyone",
restrictions)
+                hasPermission("/testroot/secured", true, new String[]{"jcr:all"}, "everyone",
restrictions) >= 0
         );
     }
 
@@ -277,7 +325,6 @@ public class TestACLAndMerge extends Int
      * Installs a package with missing ACL user.
      */
     @Test
-    @Ignore("current fails due to changes related to JCRVLT-25")
     public void testMissingUser() throws RepositoryException, IOException, PackageException
{
         assertNodeMissing("/testroot");
 
@@ -296,7 +343,7 @@ public class TestACLAndMerge extends Int
         if (globRest != null) {
             restrictions.put("rep:glob", new String[]{globRest});
         }
-        if (hasPermission(path, allow, privs, name, restrictions)) {
+        if (hasPermission(path, allow, privs, name, restrictions) >= 0) {
             fail("Expected permission should not exist on path " + path);
         }
     }
@@ -307,20 +354,21 @@ public class TestACLAndMerge extends Int
         if (globRest != null) {
             restrictions.put("rep:glob", new String[]{globRest});
         }
-        if (!hasPermission(path, allow, privs, name, restrictions)) {
+        if (hasPermission(path, allow, privs, name, restrictions) < 0) {
             fail("Expected permission missing on path " + path);
         }
     }
 
-    protected boolean hasPermission(String path, boolean allow, String[] privs, String name,
Map<String, String[]> restrictions)
+    protected int hasPermission(String path, boolean allow, String[] privs, String name,
Map<String, String[]> restrictions)
             throws RepositoryException {
         AccessControlPolicy[] ap = admin.getAccessControlManager().getPolicies(path);
-        boolean found = false;
+        int idx = 0;
         for (AccessControlPolicy p: ap) {
             if (p instanceof JackrabbitAccessControlList) {
                 JackrabbitAccessControlList acl = (JackrabbitAccessControlList) p;
                 for (AccessControlEntry ac: acl.getAccessControlEntries()) {
                     if (ac instanceof JackrabbitAccessControlEntry) {
+                        idx++;
                         JackrabbitAccessControlEntry ace = (JackrabbitAccessControlEntry)
ac;
                         if (ace.isAllow() != allow) {
                             continue;
@@ -365,12 +413,11 @@ public class TestACLAndMerge extends Int
                         if (!restrictionExpected || !rests.isEmpty()) {
                             continue;
                         }
-                        found = true;
-                        break;
+                        return idx-1;
                     }
                 }
             }
         }
-        return found;
+        return -1;
     }
 }
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/mode_ac_test_e.zip
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/mode_ac_test_e.zip?rev=1570754&view=auto
==============================================================================
Files jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/mode_ac_test_e.zip
(added) and jackrabbit/commons/filevault/trunk/vault-core/src/test/resources/org/apache/jackrabbit/vault/packaging/integration/testpackages/mode_ac_test_e.zip
Fri Feb 21 23:59:21 2014 differ



Mime
View raw message