use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testGetOakPath.
@Test
public void testGetOakPath() {
NamePathMapper npMapper = new NamePathMapperImpl(new LocalNameMapper(singletonMap("oak", "http://jackrabbit.apache.org"), singletonMap("jcr", "http://jackrabbit.apache.org")));
// map of jcr-path to oak path
Map<String, String> paths = new HashMap();
paths.put(null, null);
paths.put(TEST_PATH, TEST_PATH);
paths.put("/", "/");
String oakPath = "/oak:testPath";
String jcrPath = "/jcr:testPath";
paths.put(jcrPath, oakPath);
jcrPath = "/{http://jackrabbit.apache.org}testPath";
paths.put(jcrPath, oakPath);
// test if oak-path is properly set.
for (String path : paths.keySet()) {
AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
assertEquals(paths.get(path), acl.getOakPath());
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testSize.
@Test
public void testSize() throws RepositoryException {
AbstractAccessControlList acl = createACL(createTestEntries());
assertEquals(3, acl.size());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testGetRestrictionNames.
@Test
public void testGetRestrictionNames() throws RepositoryException {
AbstractAccessControlList acl = createEmptyACL();
String[] restrNames = acl.getRestrictionNames();
assertNotNull(restrNames);
List<String> names = Lists.newArrayList(restrNames);
for (RestrictionDefinition def : getRestrictionProvider().getSupportedRestrictions(TEST_PATH)) {
assertTrue(names.remove(getNamePathMapper().getJcrName(def.getName())));
}
assertTrue(names.isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testIsEmpty.
@Test
public void testIsEmpty() throws RepositoryException {
AbstractAccessControlList acl = createACL(createTestEntries());
assertFalse(acl.isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testReorder.
@Test
public void testReorder() throws Exception {
Privilege[] read = privilegesFromNames(JCR_READ, JCR_READ_ACCESS_CONTROL);
Privilege[] write = privilegesFromNames(JCR_WRITE);
AbstractAccessControlList acl = createEmptyACL();
acl.addAccessControlEntry(testPrincipal, read);
acl.addEntry(testPrincipal, write, false);
acl.addAccessControlEntry(EveryonePrincipal.getInstance(), write);
AccessControlEntry[] entries = acl.getAccessControlEntries();
assertEquals(3, entries.length);
AccessControlEntry first = entries[0];
AccessControlEntry second = entries[1];
AccessControlEntry third = entries[2];
// reorder 'second' to the first position
acl.orderBefore(second, first);
assertEquals(second, acl.getEntries().get(0));
assertEquals(first, acl.getEntries().get(1));
assertEquals(third, acl.getEntries().get(2));
// reorder 'third' before 'first'
acl.orderBefore(third, first);
assertEquals(second, acl.getEntries().get(0));
assertEquals(third, acl.getEntries().get(1));
assertEquals(first, acl.getEntries().get(2));
}
Aggregations