use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testRemovePrincipals.
@Test
public void testRemovePrincipals() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.BESTEFFORT, ImmutableSet.of(testPrincipal, EveryonePrincipal.getInstance()));
assertFalse(cug.removePrincipals(new PrincipalImpl("unknown")));
assertTrue(cug.removePrincipals(testPrincipal, EveryonePrincipal.getInstance(), new PrincipalImpl("unknown")));
assertTrue(cug.getPrincipals().isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddEmptyPrincipalName.
@Test(expected = AccessControlException.class)
public void testAddEmptyPrincipalName() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.BESTEFFORT);
cug.addPrincipals(new PrincipalImpl(""));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testGetPathWithRemapping.
@Test
public void testGetPathWithRemapping() {
String oakPath = "/oak:testPath";
NamePathMapper mapper = new NamePathMapperImpl(new LocalNameMapper(root, ImmutableMap.of("quercus", "http://jackrabbit.apache.org/oak/ns/1.0")));
CugPolicy empty = new CugPolicyImpl(oakPath, mapper, principalManager, ImportBehavior.ABORT);
assertEquals("/quercus:testPath", empty.getPath());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddInvalidPrincipalsAbort.
@Test(expected = AccessControlException.class)
public void testAddInvalidPrincipalsAbort() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.ABORT);
cug.addPrincipals(EveryonePrincipal.getInstance(), new PrincipalImpl("unknown"));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testRemovePolicyRemovesMixin.
@Test
public void testRemovePolicyRemovesMixin() throws Exception {
ReadOnlyNodeTypeManager ntMgr = ReadOnlyNodeTypeManager.getInstance(root, NamePathMapper.DEFAULT);
CugPolicy cug = getApplicableCug(SUPPORTED_PATH);
cugAccessControlManager.setPolicy(SUPPORTED_PATH, cug);
root.commit();
assertTrue(ntMgr.isNodeType(root.getTree(SUPPORTED_PATH), MIX_REP_CUG_MIXIN));
cugAccessControlManager.removePolicy(SUPPORTED_PATH, cugAccessControlManager.getPolicies(SUPPORTED_PATH)[0]);
root.commit();
assertFalse(ntMgr.isNodeType(root.getTree(SUPPORTED_PATH), MIX_REP_CUG_MIXIN));
}
Aggregations