You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by an...@apache.org on 2013/08/07 17:07:35 UTC

svn commit: r1511349 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java

Author: angela
Date: Wed Aug  7 15:07:35 2013
New Revision: 1511349

URL: http://svn.apache.org/r1511349
Log:
OAK-51 : Access Control Management (restriction related test cases)

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

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java?rev=1511349&r1=1511348&r2=1511349&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java Wed Aug  7 15:07:35 2013
@@ -33,6 +33,7 @@ import org.apache.jackrabbit.oak.Abstrac
 import org.apache.jackrabbit.oak.api.PropertyState;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
+import org.apache.jackrabbit.oak.plugins.memory.PropertyStates;
 import org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl;
 import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AccessControlConstants;
 import org.apache.jackrabbit.oak.util.NodeUtil;
@@ -259,13 +260,43 @@ public class AbstractRestrictionProvider
     }
 
     @Test
-    public void testReadRestrictions() {
-        // TODO
+    public void testReadRestrictionsForUnsupportedPath() throws Exception {
+        Set<Restriction> restrictions = restrictionProvider.readRestrictions(unsupportedPath, getAceTree());
+        assertTrue(restrictions.isEmpty());
     }
 
     @Test
-    public void testWriteRestrictions() {
-        // TODO
+    public void testReadRestrictions() throws Exception {
+        Restriction r = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue);
+        Tree aceTree = getAceTree(r);
+
+        Set<Restriction> restrictions = restrictionProvider.readRestrictions(testPath, aceTree);
+        assertEquals(1, restrictions.size());
+        assertTrue(restrictions.contains(r));
+    }
+
+    @Test
+    public void testWriteRestrictions() throws Exception {
+        Restriction r = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue);
+        Tree aceTree = getAceTree();
+
+        restrictionProvider.writeRestrictions(testPath, aceTree, ImmutableSet.<Restriction>of(r));
+
+        assertTrue(aceTree.hasChild(REP_RESTRICTIONS));
+        Tree restr = aceTree.getChild(REP_RESTRICTIONS);
+        assertEquals(r.getProperty(), restr.getProperty(REP_GLOB));
+    }
+
+    @Test
+    public void testWriteInvalidRestrictions() throws Exception {
+        PropertyState ps = PropertyStates.createProperty(REP_GLOB, valueFactory.createValue(false));
+        Tree aceTree = getAceTree();
+
+        restrictionProvider.writeRestrictions(testPath, aceTree, ImmutableSet.<Restriction>of(new RestrictionImpl(ps, false)));
+
+        assertTrue(aceTree.hasChild(REP_RESTRICTIONS));
+        Tree restr = aceTree.getChild(REP_RESTRICTIONS);
+        assertEquals(ps, restr.getProperty(REP_GLOB));
     }
 
     @Test