Search in sources :

Example 6 with TreeLocation

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

the class UserContextTest method testNonExistingTreeDefinesLocation2.

@Test
public void testNonExistingTreeDefinesLocation2() {
    for (String name : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
        String path = "/some/path/endingWith/reservedName/" + name;
        for (String ntName : NT_NAMES) {
            Tree t = mockTree("anyName", ntName);
            TreeLocation location = Mockito.mock(TreeLocation.class);
            when(location.getTree()).thenReturn(t);
            when(location.exists()).thenReturn(false);
            when(location.getPath()).thenReturn(path);
            assertTrue(ctx.definesLocation(location));
        }
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Tree(org.apache.jackrabbit.oak.api.Tree) Test(org.junit.Test)

Example 7 with TreeLocation

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

the class PrivilegeContextTest method testDefinesLocation.

@Test
public void testDefinesLocation() {
    List<String> paths = ImmutableList.of(PrivilegeConstants.PRIVILEGES_PATH, PrivilegeConstants.PRIVILEGES_PATH + "/child", PrivilegeConstants.PRIVILEGES_PATH + "/another/child");
    for (String path : paths) {
        TreeLocation location = Mockito.mock(TreeLocation.class);
        when(location.getPath()).thenReturn(path);
        assertTrue(path, ctx.definesLocation(location));
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Test(org.junit.Test)

Example 8 with TreeLocation

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

the class PrivilegeContextTest method testNotDefinesLocation.

@Test
public void testNotDefinesLocation() {
    List<String> paths = ImmutableList.of(PathUtils.ROOT_PATH, PrivilegeConstants.PRIVILEGES_PATH + "sibling", "/some/other/path", "");
    for (String path : paths) {
        TreeLocation location = Mockito.mock(TreeLocation.class);
        when(location.getPath()).thenReturn(path);
        assertFalse(path, ctx.definesLocation(location));
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Test(org.junit.Test)

Example 9 with TreeLocation

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

the class UserContextTest method testDefinesLocation.

@Test
public void testDefinesLocation() {
    for (String ntName : NT_NAMES) {
        Tree t = mockTree("anyName", ntName);
        TreeLocation location = Mockito.mock(TreeLocation.class);
        when(location.getTree()).thenReturn(t);
        when(location.exists()).thenReturn(true);
        assertTrue(ctx.definesLocation(location));
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Tree(org.apache.jackrabbit.oak.api.Tree) Test(org.junit.Test)

Example 10 with TreeLocation

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

the class UserContextTest method testNoTreeDefinesLocation.

@Test
public void testNoTreeDefinesLocation() {
    for (String name : Iterables.concat(USER_PROPERTY_NAMES, GROUP_PROPERTY_NAMES)) {
        String path = "/some/path/endingWith/reservedName/" + name;
        TreeLocation location = Mockito.mock(TreeLocation.class);
        when(location.getPath()).thenReturn(path);
        assertTrue(path, ctx.definesLocation(location));
    }
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Test(org.junit.Test)

Aggregations

TreeLocation (org.apache.jackrabbit.oak.plugins.tree.TreeLocation)27 Test (org.junit.Test)21 Tree (org.apache.jackrabbit.oak.api.Tree)7 PropertyState (org.apache.jackrabbit.oak.api.PropertyState)4 ImmutableMap (com.google.common.collect.ImmutableMap)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)2 Root (org.apache.jackrabbit.oak.api.Root)2 PrivilegedAction (java.security.PrivilegedAction)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Nonnull (javax.annotation.Nonnull)1 GuestCredentials (javax.jcr.GuestCredentials)1 RepositoryException (javax.jcr.RepositoryException)1 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)1 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)1 ImmutableTree (org.apache.jackrabbit.oak.plugins.tree.impl.ImmutableTree)1 AggregatedPermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.AggregatedPermissionProvider)1 PermissionProvider (org.apache.jackrabbit.oak.spi.security.authorization.permission.PermissionProvider)1