use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testReorderToTheEnd.
@Test
public void testReorderToTheEnd() 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);
List<? extends JackrabbitAccessControlEntry> entries = acl.getEntries();
assertEquals(3, entries.size());
AccessControlEntry first = entries.get(0);
acl.orderBefore(first, null);
List<? extends JackrabbitAccessControlEntry> entriesAfter = acl.getEntries();
assertEquals(first, entriesAfter.get(2));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testGetEntries.
@Test
public void testGetEntries() throws RepositoryException {
List<ACE> aces = createTestEntries();
AbstractAccessControlList acl = createACL(TEST_PATH, aces, getNamePathMapper());
assertNotNull(acl.getEntries());
assertNotNull(acl.getAccessControlEntries());
assertEquals(aces.size(), acl.getEntries().size());
assertEquals(aces.size(), acl.getAccessControlEntries().length);
assertTrue(acl.getEntries().containsAll(aces));
assertTrue(Arrays.asList(acl.getAccessControlEntries()).containsAll(aces));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testEmptyAcl.
@Test
public void testEmptyAcl() throws RepositoryException {
AbstractAccessControlList acl = createEmptyACL();
assertNotNull(acl.getAccessControlEntries());
assertNotNull(acl.getEntries());
assertTrue(acl.getAccessControlEntries().length == 0);
assertEquals(acl.getAccessControlEntries().length, acl.getEntries().size());
assertEquals(0, acl.size());
assertTrue(acl.isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testGetPath.
@Test
public void testGetPath() {
NameMapper nameMapper = new GlobalNameMapper(Collections.singletonMap("jr", "http://jackrabbit.apache.org"));
NamePathMapper npMapper = new NamePathMapperImpl(nameMapper);
// map of jcr-path to standard jcr-path
Map<String, String> paths = new HashMap<String, String>();
paths.put(null, null);
paths.put(TEST_PATH, TEST_PATH);
paths.put("/", "/");
paths.put("/jr:testPath", "/jr:testPath");
paths.put("/{http://jackrabbit.apache.org}testPath", "/jr:testPath");
for (String path : paths.keySet()) {
AbstractAccessControlList acl = createACL(path, Collections.<ACE>emptyList(), npMapper);
assertEquals(paths.get(path), acl.getPath());
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlList in project jackrabbit-oak by apache.
the class ACLTest method testGetRestrictionTypeForUnknownName.
@Test
public void testGetRestrictionTypeForUnknownName() throws RepositoryException {
AbstractAccessControlList acl = createEmptyACL();
// for backwards compatibility getRestrictionType(String) must return
// UNDEFINED for a unknown restriction name:
assertEquals(PropertyType.UNDEFINED, acl.getRestrictionType("unknownRestrictionName"));
}
Aggregations