use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class CompositeRestrictionProviderTest method testReadRestrictions.
@Test
public void testReadRestrictions() throws Exception {
NodeUtil aceNode = new NodeUtil(root.getTree("/")).addChild("test", NT_REP_GRANT_ACE);
aceNode.setBoolean("boolean", true);
aceNode.setValues("longs", new Value[] { vf.createValue(10), vf.createValue(290) });
aceNode.setString(REP_GLOB, "*");
// empty array
aceNode.setNames(REP_NT_NAMES);
aceNode.setString("invalid", "val");
aceNode.setStrings("invalid2", "val1", "val2", "val3");
Set<Restriction> restrictions = provider.readRestrictions("/test", aceNode.getTree());
assertEquals(4, restrictions.size());
for (Restriction r : restrictions) {
String name = r.getDefinition().getName();
if (!supported.contains(name)) {
fail("read unsupported restriction");
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project sling by apache.
the class SlingRestrictionProviderImplTest method testGetPatternFromRestrictionsResourceTypesWithDescendants.
@Test
public void testGetPatternFromRestrictionsResourceTypesWithDescendants() {
doReturn(SlingRestrictionProviderImpl.SLING_RESOURCE_TYPES_WITH_DESCENDANTS).when(definition).getName();
doReturn(Arrays.asList(RESOURCE_TYPE1, RESOURCE_TYPE2)).when(restrictionProperty).getValue(Type.STRINGS);
slingRestrictionProviderImpl = new SlingRestrictionProviderImpl();
RestrictionPattern pattern = slingRestrictionProviderImpl.getPattern(TEST_PATH, new HashSet<Restriction>(Arrays.asList(restriction)));
assertTrue(pattern instanceof ResourceTypePattern);
ResourceTypePattern resourceTypePattern = (ResourceTypePattern) pattern;
assertTrue(resourceTypePattern.isMatchChildren());
assertEquals(TEST_PATH, resourceTypePattern.getLimitedToPath());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project sling by apache.
the class SlingRestrictionProviderImplTest method testGetPatternFromRestrictionsResourceTypes.
@Test
public void testGetPatternFromRestrictionsResourceTypes() {
doReturn(SlingRestrictionProviderImpl.SLING_RESOURCE_TYPES).when(definition).getName();
doReturn(Arrays.asList(RESOURCE_TYPE1, RESOURCE_TYPE2)).when(restrictionProperty).getValue(Type.STRINGS);
slingRestrictionProviderImpl = new SlingRestrictionProviderImpl();
RestrictionPattern pattern = slingRestrictionProviderImpl.getPattern(TEST_PATH, new HashSet<Restriction>(Arrays.asList(restriction)));
assertTrue(pattern instanceof ResourceTypePattern);
ResourceTypePattern resourceTypePattern = (ResourceTypePattern) pattern;
assertFalse(resourceTypePattern.isMatchChildren());
assertEquals(TEST_PATH, resourceTypePattern.getLimitedToPath());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class EntryTest method testGetRestrictionForMultiValued2.
/**
* @since OAK 1.0: support for multi-value restrictions
*/
@Test
public void testGetRestrictionForMultiValued2() throws Exception {
// single value restriction stored in multi-value property
Restriction singleNameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, new Value[] { nameValue });
ACE ace = createEntry(ImmutableSet.of(singleNameRestr));
Value val = ace.getRestriction(AccessControlConstants.REP_NT_NAMES);
assertEquals(nameValue, val);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction in project jackrabbit-oak by apache.
the class EntryTest method testGetRestrictionForMultiValued.
/**
* @since OAK 1.0: support for multi-value restrictions
*/
@Test(expected = ValueFormatException.class)
public void testGetRestrictionForMultiValued() throws Exception {
// multivalued restriction
Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
ACE ace = createEntry(ImmutableSet.of(nameRestr));
ace.getRestriction(AccessControlConstants.REP_NT_NAMES);
}
Aggregations