PermissionUtil implements PermissionConstants { public static boolean checkACLPath(@NotNull NodeBuilder node, @NotNull String path) { PropertyState property = node.getProperty(REP_ACCESS_CONTROLLED_PATH); return property != null && path.equals(property.getValue(Type.STRING)); } private  PermissionUtil(); @Nullable static String getParentPathOrNull(@NotNull final String path); @NotNull static String getEntryName(@Nullable String accessControlledPath); static boolean checkACLPath(@NotNull NodeBuilder node, @NotNull String path); static boolean checkACLPath(@NotNull Tree node, @NotNull String path); @NotNull static Tree getPermissionsRoot(@NotNull Root root, @NotNull String permissionRootName); @NotNull static Tree getPrincipalRoot(@NotNull Tree permissionsTree, @NotNull String principalName); static boolean isAdminOrSystem(@NotNull Set<Principal> principals, @NotNull ConfigurationParameters config); @Nullable static String getPath(@Nullable Tree parentBefore, @Nullable Tree parentAfter); @Nullable static Tree getReadOnlyTreeOrNull(@Nullable Tree tree, @NotNull Root readOnlyRoot); @NotNull static Tree getReadOnlyTree(@NotNull Tree tree, @NotNull Root readOnlyRoot);  }
@Test public void testCheckACLPath() { Tree tree = mock(Tree.class); String path = "/path"; when(tree.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(null); assertFalse(PermissionUtil.checkACLPath(tree, path)); PropertyState nonMatching = PropertyStates.createProperty(REP_ACCESS_CONTROLLED_PATH, "/another"); when(tree.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(nonMatching); assertFalse(PermissionUtil.checkACLPath(tree, path)); PropertyState matching = PropertyStates.createProperty(REP_ACCESS_CONTROLLED_PATH, "/path"); when(tree.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(matching); assertTrue(PermissionUtil.checkACLPath(tree, path)); }
@Test public void testCheckACLPath2() { NodeBuilder nb = mock(NodeBuilder.class); String path = "/path"; when(nb.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(null); assertFalse(PermissionUtil.checkACLPath(nb, path)); PropertyState nonMatching = PropertyStates.createProperty(REP_ACCESS_CONTROLLED_PATH, "/another"); when(nb.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(nonMatching); assertFalse(PermissionUtil.checkACLPath(nb, path)); PropertyState matching = PropertyStates.createProperty(REP_ACCESS_CONTROLLED_PATH, "/path"); when(nb.getProperty(REP_ACCESS_CONTROLLED_PATH)).thenReturn(matching); assertTrue(PermissionUtil.checkACLPath(nb, path)); }