Search in sources :

Example 26 with TreeLocation

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

the class PermissionsTest method testActionRead.

@Test
public void testActionRead() {
    TreeLocation treeLocation = TreeLocation.create(existingTree);
    assertNull(treeLocation.getProperty());
    assertEquals(Permissions.READ_NODE, Permissions.getPermissions(Session.ACTION_READ, treeLocation, false));
    assertEquals(Permissions.READ_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_READ, treeLocation, true));
    TreeLocation nonExistingTree = createNonExistingTreeLocation("/nonExisting");
    assertNull(nonExistingTree.getProperty());
    assertEquals(Permissions.READ, Permissions.getPermissions(Session.ACTION_READ, nonExistingTree, false));
    assertEquals(Permissions.READ_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_READ, nonExistingTree, true));
    TreeLocation nonExistingProp = createNonExistingTreeLocation("/nonExisting").getChild("nonExisting");
    assertNull(nonExistingProp.getProperty());
    assertEquals(Permissions.READ, Permissions.getPermissions(Session.ACTION_READ, nonExistingProp, false));
    assertEquals(Permissions.READ_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_READ, nonExistingProp, true));
    TreeLocation existingProp = treeLocation.getChild(JcrConstants.JCR_PRIMARYTYPE);
    assertNotNull(existingProp.getProperty());
    assertEquals(Permissions.READ_PROPERTY, Permissions.getPermissions(Session.ACTION_READ, existingProp, false));
    assertEquals(Permissions.READ_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_READ, existingProp, true));
}
Also used : TreeLocation(org.apache.jackrabbit.oak.plugins.tree.TreeLocation) Test(org.junit.Test)

Example 27 with TreeLocation

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

the class PermissionsTest method testActionSetProperty.

@Test
public void testActionSetProperty() {
    TreeLocation treeLocation = TreeLocation.create(existingTree);
    assertNull(treeLocation.getProperty());
    assertEquals(Permissions.ADD_PROPERTY, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, treeLocation, false));
    assertEquals(Permissions.MODIFY_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, treeLocation, true));
    TreeLocation nonExistingTree = createNonExistingTreeLocation("/nonExisting");
    assertNull(nonExistingTree.getProperty());
    assertEquals(Permissions.ADD_PROPERTY, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, nonExistingTree, false));
    assertEquals(Permissions.MODIFY_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, nonExistingTree, true));
    TreeLocation nonExistingProp = createNonExistingTreeLocation("/nonExisting").getChild("nonExisting");
    assertNull(nonExistingProp.getProperty());
    assertEquals(Permissions.ADD_PROPERTY, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, nonExistingProp, false));
    assertEquals(Permissions.MODIFY_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, nonExistingProp, true));
    TreeLocation existingProp = treeLocation.getChild(JcrConstants.JCR_PRIMARYTYPE);
    assertNotNull(existingProp.getProperty());
    assertEquals(Permissions.MODIFY_PROPERTY, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, existingProp, false));
    assertEquals(Permissions.MODIFY_ACCESS_CONTROL, Permissions.getPermissions(Session.ACTION_SET_PROPERTY, existingProp, true));
}
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