Search in sources :

Example 16 with ImmutableTree

use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.

the class AbstractCompositeProviderTest method testTreePermissionGetChild.

@Test
public void testTreePermissionGetChild() throws Exception {
    List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
    Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
    NodeState ns = ((ImmutableTree) rootTree).getNodeState();
    TreePermission tp = createPermissionProvider().getTreePermission(rootTree, TreePermission.EMPTY);
    for (String cName : childNames) {
        ns = ns.getChildNode(cName);
        tp = tp.getChildPermission(cName, ns);
        assertCompositeTreePermission(tp);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Example 17 with ImmutableTree

use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.

the class CompositeProviderCoverageTest method testTreePermissionGetChild.

@Test
public void testTreePermissionGetChild() throws Exception {
    List<String> childNames = ImmutableList.of("test", "a", "b", "c", "nonexisting");
    Tree rootTree = readOnlyRoot.getTree(ROOT_PATH);
    NodeState ns = ((ImmutableTree) rootTree).getNodeState();
    TreePermission tp = createPermissionProvider().getTreePermission(rootTree, TreePermission.EMPTY);
    for (String cName : childNames) {
        ns = ns.getChildNode(cName);
        tp = tp.getChildPermission(cName, ns);
        assertTrue(tp instanceof LimitedTreePermission);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) Test(org.junit.Test)

Example 18 with ImmutableTree

use of org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree in project jackrabbit-oak by apache.

the class VersionTreePermissionTest method testGetChild.

@Test
public void testGetChild() throws Exception {
    Tree versionHistory = checkNotNull(vMgr.getVersionHistory(testTree));
    ImmutableTree t = (ImmutableTree) RootFactory.createReadOnlyRoot(root).getTree("/");
    TreePermission tp = pp.getTreePermission(t, TreePermission.EMPTY);
    for (String name : PathUtils.elements(versionHistory.getPath())) {
        t = t.getChild(name);
        tp = tp.getChildPermission(name, t.getNodeState());
    }
    String expectedPath = "/test";
    assertVersionPermission(tp, "/test", true);
    NodeState ns = t.getChild("1.0").getNodeState();
    tp = tp.getChildPermission("1.0", ns);
    assertVersionPermission(tp, "/test", true);
    ns = ns.getChildNode(JCR_FROZENNODE);
    tp = tp.getChildPermission(JCR_FROZENNODE, ns);
    assertVersionPermission(tp, "/test", true);
    for (String name : new String[] { "a", "b", "c" }) {
        ns = ns.getChildNode(name);
        expectedPath = PathUtils.concat(expectedPath, name);
        tp = tp.getChildPermission(name, ns);
        assertVersionPermission(tp, expectedPath, true);
    }
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) Tree(org.apache.jackrabbit.oak.api.Tree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) ImmutableTree(org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree) TreePermission(org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission) AbstractSecurityTest(org.apache.jackrabbit.oak.AbstractSecurityTest) Test(org.junit.Test)

Aggregations

ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)18 Test (org.junit.Test)10 Tree (org.apache.jackrabbit.oak.api.Tree)8 TreePermission (org.apache.jackrabbit.oak.spi.security.authorization.permission.TreePermission)7 NodeState (org.apache.jackrabbit.oak.spi.state.NodeState)6 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)3 Nonnull (javax.annotation.Nonnull)2 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)2 PrivilegeBits (org.apache.jackrabbit.oak.spi.security.privilege.PrivilegeBits)2 NodeBuilder (org.apache.jackrabbit.oak.spi.state.NodeBuilder)2 Field (java.lang.reflect.Field)1 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)1 EmptyNodeState (org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState)1 MemoryNodeBuilder (org.apache.jackrabbit.oak.plugins.memory.MemoryNodeBuilder)1 TreeType (org.apache.jackrabbit.oak.plugins.tree.TreeType)1 Validator (org.apache.jackrabbit.oak.spi.commit.Validator)1 VisibleValidator (org.apache.jackrabbit.oak.spi.commit.VisibleValidator)1 Before (org.junit.Before)1