use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositePattern in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testGetRestrictionPattern.
@Test
public void testGetRestrictionPattern() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
NodeUtil rNode = aceNode.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS);
rNode.setString(REP_GLOB, "*");
assertFalse(provider.getPattern("/test", aceNode.getTree()) instanceof CompositePattern);
rNode.setBoolean("boolean", true);
rNode.setValues("longs", new Value[] { vf.createValue(10), vf.createValue(290) });
assertTrue(provider.getPattern("/test", rNode.getTree()) instanceof CompositePattern);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositePattern in project jackrabbit-oak by apache.
the class RestrictionProviderImplTest method testGetPatternForAllSupported.
@Test
public void testGetPatternForAllSupported() throws Exception {
Map<PropertyState, RestrictionPattern> map = newHashMap();
map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content"));
List<String> ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE);
map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames));
List<String> prefixes = ImmutableList.of("rep", "jcr");
map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes));
List<String> itemNames = ImmutableList.of("abc", "jcr:primaryType");
map.put(PropertyStates.createProperty(REP_ITEM_NAMES, prefixes, Type.NAMES), new ItemNamePattern(itemNames));
NodeUtil tree = new NodeUtil(root.getTree("/")).getOrAddTree("testPath", JcrConstants.NT_UNSTRUCTURED);
Tree restrictions = tree.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS).getTree();
for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
restrictions.setProperty(entry.getKey());
}
RestrictionPattern pattern = provider.getPattern("/testPath", restrictions);
assertTrue(pattern instanceof CompositePattern);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositePattern in project jackrabbit-oak by apache.
the class RestrictionProviderImplTest method testGetRestrictionPattern.
@Test
public void testGetRestrictionPattern() throws Exception {
Map<PropertyState, RestrictionPattern> map = newHashMap();
map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content"));
List<String> ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE);
map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames));
NodeUtil tree = new NodeUtil(root.getTree("/")).getOrAddTree("testPath", JcrConstants.NT_UNSTRUCTURED);
Tree restrictions = tree.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS).getTree();
// test restrictions individually
for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
restrictions.setProperty(entry.getKey());
RestrictionPattern pattern = provider.getPattern("/testPath", restrictions);
assertEquals(entry.getValue(), pattern);
restrictions.removeProperty(entry.getKey().getName());
}
// test combination on multiple restrictions
for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
restrictions.setProperty(entry.getKey());
}
RestrictionPattern pattern = provider.getPattern("/testPath", restrictions);
assertTrue(pattern instanceof CompositePattern);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.CompositePattern in project jackrabbit-oak by apache.
the class RestrictionProviderImplTest method testGetPatternFromRestrictions.
@Test
public void testGetPatternFromRestrictions() throws Exception {
Map<PropertyState, RestrictionPattern> map = newHashMap();
map.put(PropertyStates.createProperty(REP_GLOB, "/*/jcr:content"), GlobPattern.create("/testPath", "/*/jcr:content"));
List<String> ntNames = ImmutableList.of(JcrConstants.NT_FOLDER, JcrConstants.NT_LINKEDFILE);
map.put(PropertyStates.createProperty(REP_NT_NAMES, ntNames, Type.NAMES), new NodeTypePattern(ntNames));
List<String> prefixes = ImmutableList.of("rep", "jcr");
map.put(PropertyStates.createProperty(REP_PREFIXES, prefixes, Type.STRINGS), new PrefixPattern(prefixes));
List<String> itemNames = ImmutableList.of("abc", "jcr:primaryType");
map.put(PropertyStates.createProperty(REP_ITEM_NAMES, itemNames, Type.NAMES), new ItemNamePattern(itemNames));
NodeUtil tree = new NodeUtil(root.getTree("/")).getOrAddTree("testPath", JcrConstants.NT_UNSTRUCTURED);
Tree restrictions = tree.addChild(REP_RESTRICTIONS, NT_REP_RESTRICTIONS).getTree();
// test restrictions individually
for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
restrictions.setProperty(entry.getKey());
RestrictionPattern pattern = provider.getPattern("/testPath", provider.readRestrictions("/testPath", tree.getTree()));
assertEquals(entry.getValue(), pattern);
restrictions.removeProperty(entry.getKey().getName());
}
// test combination on multiple restrictions
for (Map.Entry<PropertyState, RestrictionPattern> entry : map.entrySet()) {
restrictions.setProperty(entry.getKey());
}
RestrictionPattern pattern = provider.getPattern("/testPath", provider.readRestrictions("/testPath", tree.getTree()));
assertTrue(pattern instanceof CompositePattern);
}
Aggregations