use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testSetPolicy.
@Test
public void testSetPolicy() throws Exception {
CugPolicy cug = getApplicableCug(SUPPORTED_PATH);
cug.addPrincipals(EveryonePrincipal.getInstance());
cugAccessControlManager.setPolicy(SUPPORTED_PATH, cug);
AccessControlPolicy[] policies = cugAccessControlManager.getPolicies(SUPPORTED_PATH);
assertEquals(1, policies.length);
AccessControlPolicy policy = policies[0];
assertTrue(policy instanceof CugPolicyImpl);
Set<Principal> principals = ((CugPolicy) policy).getPrincipals();
assertEquals(1, principals.size());
assertEquals(EveryonePrincipal.getInstance(), principals.iterator().next());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testRemovePolicyPersisted.
@Test
public void testRemovePolicyPersisted() throws Exception {
CugPolicy cug = getApplicableCug(SUPPORTED_PATH);
cugAccessControlManager.setPolicy(SUPPORTED_PATH, cug);
root.commit();
cugAccessControlManager.removePolicy(SUPPORTED_PATH, cugAccessControlManager.getPolicies(SUPPORTED_PATH)[0]);
root.commit();
Tree tree = root.getTree(SUPPORTED_PATH);
assertFalse(tree.hasChild(CugConstants.REP_CUG_POLICY));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddContainedPrincipal.
@Test
public void testAddContainedPrincipal() throws Exception {
CugPolicy cug = new CugPolicyImpl(path, NamePathMapper.DEFAULT, principalManager, ImportBehavior.BESTEFFORT, principals);
assertFalse(cug.addPrincipals(new PrincipalImpl("test")));
assertEquals(principals, cug.getPrincipals());
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testAddPrincipals.
@Test
public void testAddPrincipals() throws Exception {
CugPolicy empty = createEmptyCugPolicy();
assertTrue(empty.addPrincipals(EveryonePrincipal.getInstance()));
assertFalse(empty.addPrincipals(EveryonePrincipal.getInstance()));
CugPolicy cug = createCugPolicy(principals);
assertTrue(cug.addPrincipals(EveryonePrincipal.getInstance()));
assertFalse(cug.addPrincipals(EveryonePrincipal.getInstance()));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.cug.CugPolicy in project jackrabbit-oak by apache.
the class CugPolicyImplTest method testGetPath.
@Test
public void testGetPath() {
CugPolicy empty = createEmptyCugPolicy();
assertEquals(path, empty.getPath());
}
Aggregations