use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE in project jackrabbit-oak by apache.
the class EntryTest method testAggregatePrivileges.
@Test
public void testAggregatePrivileges() throws Exception {
ACE ace = createEntry(PrivilegeConstants.REP_READ_NODES, PrivilegeConstants.REP_READ_PROPERTIES);
assertEquals(getBitsProvider().getBits(PrivilegeConstants.JCR_READ), ace.getPrivilegeBits());
assertArrayEquals(privilegesFromNames(PrivilegeConstants.JCR_READ), ace.getPrivileges());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE in project jackrabbit-oak by apache.
the class EntryTest method testIsAllow.
@Test
public void testIsAllow() throws RepositoryException {
ACE ace = createEntry(new String[] { PrivilegeConstants.JCR_READ }, true);
assertTrue(ace.isAllow());
ace = createEntry(new String[] { PrivilegeConstants.JCR_READ }, false);
assertFalse(ace.isAllow());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE in project jackrabbit-oak by apache.
the class EntryTest method testGetRestrictionsNone.
@Test
public void testGetRestrictionsNone() throws Exception {
ACE ace = createEntry(ImmutableSet.<Restriction>of());
assertTrue(ace.getRestrictions().isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE in project jackrabbit-oak by apache.
the class EntryTest method testGetPrivileges.
@Test
public void testGetPrivileges() throws RepositoryException {
ACE entry = createEntry(new String[] { PrivilegeConstants.JCR_READ }, true);
Privilege[] privs = entry.getPrivileges();
assertNotNull(privs);
assertEquals(1, privs.length);
assertEquals(privs[0], acMgr.privilegeFromName(PrivilegeConstants.JCR_READ));
entry = createEntry(new String[] { PrivilegeConstants.REP_WRITE }, true);
privs = entry.getPrivileges();
assertNotNull(privs);
assertEquals(1, privs.length);
assertEquals(privs[0], acMgr.privilegeFromName(PrivilegeConstants.REP_WRITE));
entry = createEntry(new String[] { PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES }, true);
privs = entry.getPrivileges();
assertNotNull(privs);
assertEquals(2, privs.length);
Privilege[] expected = AccessControlUtils.privilegesFromNames(acMgr, PrivilegeConstants.JCR_ADD_CHILD_NODES, PrivilegeConstants.JCR_REMOVE_CHILD_NODES);
assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(privs));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ACE in project jackrabbit-oak by apache.
the class EntryTest method testGetNonExistingRestrictions.
/**
* @since OAK 1.0: support for multi-value restrictions
*/
@Test
public void testGetNonExistingRestrictions() throws Exception {
Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
ACE ace = createEntry(ImmutableSet.of(nameRestr));
assertNull(ace.getRestrictions(AccessControlConstants.REP_GLOB));
}
Aggregations