use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderEmptyTest method testTreePermissionCanRead.
@Test
public void testTreePermissionCanRead() throws Exception {
TreePermission parentPermission = TreePermission.EMPTY;
for (String path : TP_PATHS) {
Tree t = readOnlyRoot.getTree(path);
TreePermission tp = cpp.getTreePermission(t, parentPermission);
assertFalse(tp.canRead());
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderFullScopeTest method testTreePermissionIsGranted.
@Test
public void testTreePermissionIsGranted() throws Exception {
TreePermission parentPermission = TreePermission.EMPTY;
for (String path : TP_PATHS) {
TreePermission tp = cppTestUser.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
Long toTest = (defPermissions.containsKey(path)) ? defPermissions.get(path) : defPermissions.get(PathUtils.getAncestorPath(path, 1));
if (toTest != null) {
if (Permissions.READ_NODE == toTest) {
assertTrue(path, tp.isGranted(toTest));
} else {
boolean canRead = Permissions.includes(toTest, Permissions.READ_NODE);
assertEquals(path, canRead, tp.isGranted(Permissions.READ_NODE));
assertFalse(path, tp.isGranted(toTest));
}
}
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderFullScopeTest method testTreePermissionCanReadProperty.
@Test
public void testTreePermissionCanReadProperty() throws Exception {
TreePermission parentPermission = TreePermission.EMPTY;
for (String nodePath : TP_PATHS) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppTestUser.getTreePermission(tree, parentPermission);
assertFalse(nodePath, tp.canRead(PROPERTY_STATE));
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionCanRead.
@Test
public void testTreePermissionCanRead() throws Exception {
Map<String, Boolean> readMap = ImmutableMap.<String, Boolean>builder().put(ROOT_PATH, false).put(TEST_PATH, true).put(TEST_A_PATH, true).put(TEST_A_B_PATH, true).put(TEST_A_B_C_PATH, false).put(TEST_A_B_C_PATH + "/nonexisting", false).build();
TreePermission parentPermission = TreePermission.EMPTY;
TreePermission parentPermission2 = TreePermission.EMPTY;
for (String nodePath : readMap.keySet()) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppTestUser.getTreePermission(tree, parentPermission);
TreePermission tp2 = defTestUser.getTreePermission(tree, parentPermission2);
boolean expectedResult = readMap.get(nodePath);
assertEquals(nodePath, expectedResult, tp.canRead());
assertEquals(nodePath + "(default)", expectedResult, tp2.canRead());
parentPermission = tp;
parentPermission2 = tp2;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionCanReadProperty.
@Test
public void testTreePermissionCanReadProperty() throws Exception {
Map<String, Boolean> readMap = ImmutableMap.<String, Boolean>builder().put(ROOT_PATH, false).put(TEST_PATH, true).put(TEST_A_PATH, true).put(TEST_A_B_PATH, true).put(TEST_A_B_C_PATH, true).put(TEST_A_B_C_PATH + "/nonexisting", true).build();
TreePermission parentPermission = TreePermission.EMPTY;
TreePermission parentPermission2 = TreePermission.EMPTY;
for (String nodePath : readMap.keySet()) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppTestUser.getTreePermission(tree, parentPermission);
TreePermission tp2 = defTestUser.getTreePermission(tree, parentPermission2);
boolean expectedResult = readMap.get(nodePath);
assertEquals(nodePath, expectedResult, tp.canRead(PROPERTY_STATE));
assertEquals(nodePath + "(default)", expectedResult, tp2.canRead(PROPERTY_STATE));
parentPermission = tp;
parentPermission2 = tp2;
}
}
Aggregations