Search in sources :

Example 51 with NodeUtil

use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.

the class PermissionProviderImplTest method before.

@Override
public void before() throws Exception {
    super.before();
    new NodeUtil(root.getTree("/")).addChild("test", JcrConstants.NT_UNSTRUCTURED);
    UserManager uMgr = getUserManager(root);
    adminstrators = uMgr.createGroup(ADMINISTRATOR_GROUP);
    root.commit();
    config = getSecurityProvider().getConfiguration(AuthorizationConfiguration.class);
}
Also used : AuthorizationConfiguration(org.apache.jackrabbit.oak.spi.security.authorization.AuthorizationConfiguration) UserManager(org.apache.jackrabbit.api.security.user.UserManager) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil)

Example 52 with NodeUtil

use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.

the class CugValidatorTest method testChangePrimaryTypeOfCug.

@Test
public void testChangePrimaryTypeOfCug() throws Exception {
    node.setNames(JcrConstants.JCR_MIXINTYPES, MIX_REP_CUG_MIXIN);
    NodeUtil cug = node.addChild(REP_CUG_POLICY, NT_REP_CUG_POLICY);
    cug.setStrings(REP_PRINCIPAL_NAMES, EveryonePrincipal.NAME);
    root.commit();
    try {
        cug.setName(JcrConstants.JCR_PRIMARYTYPE, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
        root.commit();
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isAccessControlViolation());
        assertEquals(21, e.getCode());
    }
}
Also used : CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Test(org.junit.Test)

Example 53 with NodeUtil

use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.

the class CugValidatorTest method testMissingMixin.

@Test
public void testMissingMixin() throws Exception {
    NodeUtil cug = node.addChild(REP_CUG_POLICY, NT_REP_CUG_POLICY);
    cug.setStrings(REP_PRINCIPAL_NAMES, EveryonePrincipal.NAME);
    try {
        root.commit();
        fail();
    } catch (CommitFailedException e) {
        assertTrue(e.isAccessControlViolation());
        assertEquals(22, e.getCode());
    } finally {
        root.refresh();
    }
}
Also used : CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Test(org.junit.Test)

Example 54 with NodeUtil

use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.

the class CugUtilTest method testHasCugNodeState.

@Test
public void testHasCugNodeState() throws Exception {
    assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH))));
    assertFalse(CugUtil.hasCug((NodeState) null));
    for (String path : new String[] { PathUtils.ROOT_PATH, INVALID_PATH, UNSUPPORTED_PATH, SUPPORTED_PATH + "/subtree", SUPPORTED_PATH2, SUPPORTED_PATH3 }) {
        assertFalse(CugUtil.hasCug(getNodeState(root.getTree(path))));
    }
    new NodeUtil(root.getTree(SUPPORTED_PATH2)).addChild(REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
    assertTrue(CugUtil.hasCug(getNodeState(root.getTree(SUPPORTED_PATH2))));
}
Also used : NodeState(org.apache.jackrabbit.oak.spi.state.NodeState) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Test(org.junit.Test)

Example 55 with NodeUtil

use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.

the class NestedCugHookTest method testMoveToSupportedPath.

@Test
public void testMoveToSupportedPath() throws Exception {
    createCug(root, SUPPORTED_PATH3, EveryonePrincipal.NAME);
    Tree newTree = new NodeUtil(root.getTree(SUPPORTED_PATH3)).addChild("child", NT_OAK_UNSTRUCTURED).getTree();
    String path = newTree.getPath();
    createCug(path, getTestGroupPrincipal());
    root.commit();
    String destPath = PathUtils.concat(SUPPORTED_PATH, "moved");
    root.move(path, destPath);
    root.commit();
    assertNestedCugs(root, SUPPORTED_PATH3, true);
    assertNestedCugs(root, ROOT_PATH, false, SUPPORTED_PATH3, destPath);
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) NodeUtil(org.apache.jackrabbit.oak.util.NodeUtil) Test(org.junit.Test)

Aggregations

NodeUtil (org.apache.jackrabbit.oak.util.NodeUtil)183 Test (org.junit.Test)149 AbstractSecurityTest (org.apache.jackrabbit.oak.AbstractSecurityTest)74 Tree (org.apache.jackrabbit.oak.api.Tree)67 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)59 Root (org.apache.jackrabbit.oak.api.Root)28 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)14 Before (org.junit.Before)14 JackrabbitAccessControlPolicy (org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy)13 TokenInfo (org.apache.jackrabbit.oak.spi.security.authentication.token.TokenInfo)13 AccessControlManager (javax.jcr.security.AccessControlManager)12 Principal (java.security.Principal)10 EveryonePrincipal (org.apache.jackrabbit.oak.spi.security.principal.EveryonePrincipal)8 AccessControlException (javax.jcr.security.AccessControlException)7 JackrabbitAccessControlList (org.apache.jackrabbit.api.security.JackrabbitAccessControlList)7 JackrabbitAccessControlManager (org.apache.jackrabbit.api.security.JackrabbitAccessControlManager)6 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)6 Privilege (javax.jcr.security.Privilege)5 Restriction (org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction)5 AccessControlList (javax.jcr.security.AccessControlList)4