use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class VersionTest method testCugAtRoot.
@Test
public void testCugAtRoot() throws Exception {
Tree versionable = root.getTree(UNSUPPORTED_PATH);
String vhPath = checkNotNull(versionManager.getVersionHistory(versionable)).getPath();
try {
createCug(root, PathUtils.ROOT_PATH, EveryonePrincipal.NAME);
root.commit();
CugPermissionProvider pp = createCugPermissionProvider(ImmutableSet.of("/"));
Tree t = root.getTree("/");
TreePermission tp = pp.getTreePermission(t, TreePermission.EMPTY);
assertTrue(tp instanceof CugTreePermission);
for (String segm : PathUtils.elements(vhPath)) {
t = t.getChild(segm);
tp = pp.getTreePermission(t, tp);
assertTrue(tp instanceof CugTreePermission);
}
} finally {
root.getTree("/").removeProperty(JCR_MIXINTYPES);
Tree cug = root.getTree("/rep:cugPolicy");
if (cug.exists()) {
cug.remove();
}
root.commit();
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderNoScopeTest method testTreePermissionSize.
@Test
public void testTreePermissionSize() throws Exception {
Field tpField = CompositeTreePermission.class.getDeclaredField("treePermissions");
tpField.setAccessible(true);
Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
NodeState ns = ((ImmutableTree) rootTree).getNodeState();
TreePermission tp = cppTestUser.getTreePermission(rootTree, TreePermission.EMPTY);
assertEquals(2, ((TreePermission[]) tpField.get(tp)).length);
List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
for (String cName : childNames) {
ns = ns.getChildNode(cName);
tp = tp.getChildPermission(cName, ns);
assertCompositeTreePermission(false, tp);
}
}
use of org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission in project jackrabbit-oak by apache.
the class CompositeProviderFullScopeTest method testTreePermissionIsGrantedProperty.
@Test
public void testTreePermissionIsGrantedProperty() 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) {
boolean granted = (toTest == Permissions.READ_NODE);
assertEquals(path, granted, tp.isGranted(toTest, PROPERTY_STATE));
}
assertFalse(tp.isGranted(Permissions.READ_PROPERTY, 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 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) {
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 CompositeProviderFullScopeTest 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;
for (String nodePath : readMap.keySet()) {
Tree tree = readOnlyRoot.getTree(nodePath);
TreePermission tp = cppTestUser.getTreePermission(tree, parentPermission);
boolean expectedResult = readMap.get(nodePath);
assertEquals(nodePath, expectedResult, tp.canRead());
parentPermission = tp;
}
}
Aggregations