use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testTestSessionHasRepoPrivileges.
@Test
public void testTestSessionHasRepoPrivileges() throws Exception {
AbstractAccessControlManager testAcMgr = getTestAccessControlManager();
assertFalse(testAcMgr.hasPrivileges(null, testPrivileges));
assertFalse(testAcMgr.hasPrivileges(null, getPrincipals(getTestRoot().getContentSession()), testPrivileges));
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testHasRepoPrivilegesNoAccessToPrincipals.
@Test
public void testHasRepoPrivilegesNoAccessToPrincipals() throws Exception {
AbstractAccessControlManager testAcMgr = getTestAccessControlManager();
// the test-session doesn't have sufficient permissions to read privilege set for admin session.
try {
testAcMgr.getPrivileges(null, getPrincipals(adminSession));
fail("testSession doesn't have sufficient permission to read access control information");
} catch (AccessDeniedException e) {
// success
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testHasPrivilegesNotAccessiblePath.
/**
* @since OAK 1.0 As of OAK AccessControlManager#hasPrivilege will throw
* PathNotFoundException in case the node associated with a given path is
* not readable to the editing session (compatibility with the specification
* which was missing in jackrabbit).
*/
@Test
public void testHasPrivilegesNotAccessiblePath() throws Exception {
List<String> notAccessible = new ArrayList();
notAccessible.add("/");
notAccessible.addAll(getAcContentPaths());
Privilege[] privs = privilegesFromNames(PrivilegeConstants.JCR_ALL);
AbstractAccessControlManager testAcMgr = getTestAccessControlManager();
for (String path : notAccessible) {
try {
testAcMgr.hasPrivileges(path, privs);
fail("AccessControlManager#hasPrivileges for node that is not accessible should fail.");
} catch (PathNotFoundException e) {
// success
}
}
for (String path : notAccessible) {
try {
testAcMgr.hasPrivileges(path, getPrincipals(root.getContentSession()), privs);
fail("AccessControlManager#hasPrivileges for node that is not accessible should fail.");
} catch (PathNotFoundException e) {
// success
}
}
for (String path : notAccessible) {
try {
testAcMgr.hasPrivileges(path, getPrincipals(getTestRoot().getContentSession()), privs);
fail("AccessControlManager#hasPrivileges for node that is not accessible should fail.");
} catch (PathNotFoundException e) {
// success
}
}
for (String path : notAccessible) {
try {
testAcMgr.hasPrivileges(path, ImmutableSet.<Principal>of(), privs);
fail("AccessControlManager#hasPrivileges for node that is not accessible should fail.");
} catch (PathNotFoundException e) {
// success
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.AbstractAccessControlManager in project jackrabbit-oak by apache.
the class AccessControlManagerImplTest method testHasRepoPrivilegesForEmptyPrincipalSet.
@Test(expected = AccessDeniedException.class)
public void testHasRepoPrivilegesForEmptyPrincipalSet() throws Exception {
AbstractAccessControlManager testAcMgr = getTestAccessControlManager();
// the test-session doesn't have sufficient permissions to read privilege set.
testAcMgr.getPrivileges(null, ImmutableSet.<Principal>of());
}
Aggregations