jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1511349 - /jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/spi/security/authorization/restriction/AbstractRestrictionProviderTest.java
Date Wed, 07 Aug 2013 15:07:35 GMT
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



Mime
View raw message