use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionCanReadAdmin.
@Test
public void testTreePermissionCanReadAdmin() {
TreePermission parentPermission = TreePermission.EMPTY;
TreePermission parentPermission2 = TreePermission.EMPTY;
for (String nodePath : TP_PATHS) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppAdminUser.getTreePermission(tree, parentPermission);
TreePermission tp2 = defAdminUser.getTreePermission(tree, parentPermission2);
assertTrue(nodePath, tp.canRead());
assertTrue(nodePath, tp.canRead(PROPERTY_STATE));
assertTrue(nodePath + "(default)", tp2.canRead());
assertTrue(nodePath + "(default)", tp2.canRead(PROPERTY_STATE));
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 testGetTreePermissionInstance.
@Override
@Test
public void testGetTreePermissionInstance() throws Exception {
PermissionProvider pp = createPermissionProvider();
TreePermission parentPermission = TreePermission.EMPTY;
for (String path : TP_PATHS) {
Tree t = readOnlyRoot.getTree(path);
TreePermission tp = pp.getTreePermission(t, parentPermission);
assertCompositeTreePermission(t.isRoot(), tp);
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeTreePermissionTest method testCanRead.
@Test
public void testCanRead() throws Exception {
TreePermission rootTp = createRootTreePermission(fullScopeProvider, fullScopeProvider);
Field f = CompositeTreePermission.class.getDeclaredField("canRead");
f.setAccessible(true);
Object canRead = f.get(rootTp);
assertNull(canRead);
rootTp.canRead();
canRead = f.get(rootTp);
assertNotNull(canRead);
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderScopeTest 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 (testProvider.isSupported(path)) {
assertTrue(tp.isGranted(Permissions.diff(toTest, Permissions.ADD_NODE | Permissions.ADD_PROPERTY)));
assertFalse(tp.isGranted(Permissions.ADD_PROPERTY | Permissions.ADD_NODE));
} else {
assertTrue(tp.isGranted(toTest));
}
}
parentPermission = tp;
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderScopeTest method testTreePermissionIsGrantedAdmin.
@Test
public void testTreePermissionIsGrantedAdmin() {
TreePermission parentPermission = TreePermission.EMPTY;
for (String path : TP_PATHS) {
TreePermission tp = cppAdminUser.getTreePermission(readOnlyRoot.getTree(path), parentPermission);
if (testProvider.isSupported(path)) {
assertTrue(path, tp.isGranted(Permissions.diff(Permissions.ALL, Permissions.ADD_NODE | Permissions.ADD_PROPERTY)));
assertFalse(path, tp.isGranted(Permissions.ADD_PROPERTY | Permissions.ADD_NODE));
assertFalse(path, tp.isGranted(Permissions.ALL));
} else {
assertTrue(path, tp.isGranted(Permissions.ALL));
}
parentPermission = tp;
}
parentPermission = TreePermission.EMPTY;
for (String nodePath : PATH_OUTSIDE_SCOPE) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppAdminUser.getTreePermission(tree, parentPermission);
assertTrue(nodePath, tp.isGranted(Permissions.ALL));
parentPermission = tp;
}
}
Aggregations