@Override public boolean apply(@Nullable PropertyState property) { return property != null && treePermission.canRead(property); } }
@Override public boolean hasChildNode(@NotNull String name) { if (!state.hasChildNode(name)) { return false; } else if (treePermission.canReadAll()) { return true; } else { NodeState child = state.getChildNode(name); return treePermission.getChildPermission(name, child).canRead(); } }
@Override public boolean apply(@Nullable PropertyState property) { return property != null && treePermission.canRead(property); } }
@Override @Nullable public PropertyState getProperty(@NotNull String name) { PropertyState property = state.getProperty(name); if (property != null && treePermission.canRead(property)) { return property; } else { return null; } }
@Override public boolean includeReorder(String destName, String name, NodeState reordered) { // TODO: check access to the dest name, it might not be accessible return getTreePermission().getChildPermission(name, reordered).canRead(); }
@Override public boolean apply(@Nullable PropertyState property) { if (property != null) { String propertyName = property.getName(); return NodeStateUtils.isHidden(propertyName) || getTreePermission().canRead(property) || isNew(propertyName); } else { return false; } } }
@Override public boolean apply(@Nullable PropertyState property) { if (property != null) { String propertyName = property.getName(); return NodeStateUtils.isHidden(propertyName) || getTreePermission().canRead(property) || isNew(propertyName); } else { return false; } } }
@Override public boolean exists() { return builder.exists() && (builder.isReplaced() || getTreePermission().canRead()); }
@Override public boolean isNew() { return builder.isNew() || (builder.isReplaced() && !getTreePermission().canRead()); }
@Override public boolean isNew(String name) { return builder.isNew(name) || (builder.isReplaced(name) && !getTreePermission().canRead(builder.getProperty(name))); }
@Test public void testCanRead() throws Exception { TreePermission tp = getTreePermission(accessSession, REPO_POLICY_PATH); assertTrue(tp.canRead()); }
@Test public void testTreePermissionCanReadPropertyOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { Tree t = readOnlyRoot.getTree(path); TreePermission tp = cppO.getTreePermission(t, parentPermission); assertFalse(tp.canRead(PROPERTY_STATE)); parentPermission = tp; } }
@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); assertTrue(tp.canRead()); parentPermission = tp; } }
@Test public void testTreePermissionCanReadProperty() 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(PROPERTY_STATE)); parentPermission = tp; } }
@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; } }
@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; } }
@Test public void testTreePermissionCanReadOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { Tree t = readOnlyRoot.getTree(path); TreePermission tp = cppO.getTreePermission(t, parentPermission); assertTrue(tp.canRead()); parentPermission = tp; } }
@Test public void testTreePermissionCanReadPropertyOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { Tree t = readOnlyRoot.getTree(path); TreePermission tp = cppO.getTreePermission(t, parentPermission); assertTrue(tp.canRead(PROPERTY_STATE)); parentPermission = tp; } }
@Test public void testCanReadPropertyAceNode2() throws Exception { Tree aceTree = root.getTree(REPO_POLICY_PATH).getChildren().iterator().next(); PropertyState principalProp = aceTree.getProperty(REP_PRINCIPAL_NAME); TreePermission tp = getTreePermission(noAccessSession, aceTree.getPath()); assertFalse(tp.canRead(principalProp)); }
@Test public void testTreePermissionCanReadOR() throws Exception { TreePermission parentPermission = TreePermission.EMPTY; for (String path : TP_PATHS) { Tree t = readOnlyRoot.getTree(path); TreePermission tp = cppO.getTreePermission(t, parentPermission); assertTrue(tp.canRead()); parentPermission = tp; } }