use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testWriteRestrictions.
@Test
public void testWriteRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
Set<Restriction> restrictions = ImmutableSet.of(provider.createRestriction("/test", "boolean", vf.createValue(true)), provider.createRestriction("/test", "longs"), provider.createRestriction("/test", REP_GLOB, vf.createValue("*")), provider.createRestriction("/test", REP_NT_NAMES, vf.createValue("nt:base", PropertyType.NAME), vf.createValue("nt:version", PropertyType.NAME)));
provider.writeRestrictions("/test", aceNode.getTree(), restrictions);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testReadRestrictions.
@Test
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));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testWriteRestrictions.
@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));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class AbstractRestrictionProviderTest method testValidateRestrictions.
@Test
public void testValidateRestrictions() throws Exception {
Restriction glob = restrictionProvider.createRestriction(testPath, REP_GLOB, globValue);
Restriction ntNames = restrictionProvider.createRestriction(testPath, REP_NT_NAMES, nameValues);
Restriction mand = restrictionProvider.createRestriction(testPath, "mandatory", valueFactory.createValue(true));
restrictionProvider.validateRestrictions(testPath, getAceTree(mand));
restrictionProvider.validateRestrictions(testPath, getAceTree(mand, glob));
restrictionProvider.validateRestrictions(testPath, getAceTree(mand, ntNames));
restrictionProvider.validateRestrictions(testPath, getAceTree(mand, glob, ntNames));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testWriteUnsupportedRestrictions.
@Test
public void testWriteUnsupportedRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
Restriction invalid = new RestrictionImpl(PropertyStates.createProperty("invalid", vf.createValue(true)), false);
try {
provider.writeRestrictions("/test", aceNode.getTree(), ImmutableSet.<Restriction>of(invalid));
fail("AccessControlException expected");
} catch (AccessControlException e) {
// success
}
}
Aggregations