use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testCreateReservedKeyProperty.
@Test
public void testCreateReservedKeyProperty() throws Exception {
NodeUtil node = new NodeUtil(root.getTree("/")).addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
try {
node.setString(TOKEN_ATTRIBUTE_KEY, "anyValue");
root.commit(CommitMarker.asCommitAttributes());
fail("The reserved token key property must not used with other node types.");
} catch (CommitFailedException e) {
assertEquals(60, e.getCode());
} finally {
node.getTree().remove();
root.commit();
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testManuallyCreateTokenParent.
@Test
public void testManuallyCreateTokenParent() throws Exception {
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
NodeUtil node = new NodeUtil(userTree);
node.addChild(TOKENS_NODE_NAME, TOKENS_NT_NAME);
root.commit();
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testCreateTokenAtInvalidLocationBelowTestNode.
@Test
public void testCreateTokenAtInvalidLocationBelowTestNode() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
Tree tokenTree = getTokenTree(info);
assertNotNull(tokenProvider.getTokenInfo(info.getToken()));
NodeUtil node = new NodeUtil(root.getTree("/")).addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
try {
createTokenTree(info, node, TOKEN_NT_NAME);
tokenTree.remove();
root.commit(CommitMarker.asCommitAttributes());
fail("Creating a new token not at '/testNode' must fail.");
} catch (CommitFailedException e) {
assertEquals(64, e.getCode());
} finally {
node.getTree().remove();
root.commit(CommitMarker.asCommitAttributes());
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class TokenValidatorTest method testCreateTokenAtInvalidLocationInsideUser.
@Test
public void testCreateTokenAtInvalidLocationInsideUser() throws Exception {
TokenInfo info = tokenProvider.createToken(userId, Collections.<String, Object>emptyMap());
Tree tokenTree = getTokenTree(info);
assertNotNull(tokenProvider.getTokenInfo(info.getToken()));
Tree userTree = root.getTree(getUserManager(root).getAuthorizable(userId).getPath());
NodeUtil node = new NodeUtil(userTree).addChild("testNode", JcrConstants.NT_UNSTRUCTURED);
try {
createTokenTree(info, node, TOKEN_NT_NAME);
tokenTree.remove();
root.commit(CommitMarker.asCommitAttributes());
fail("Creating a new token '" + node.getTree().getPath() + "' must fail.");
} catch (CommitFailedException e) {
assertEquals(65, e.getCode());
} finally {
node.getTree().remove();
root.commit(CommitMarker.asCommitAttributes());
}
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugContextTest method before.
@Before
@Override
public void before() throws Exception {
super.before();
// add more child nodes
NodeUtil n = new NodeUtil(root.getTree(SUPPORTED_PATH));
n.addChild("a", NT_OAK_UNSTRUCTURED).addChild("b", NT_OAK_UNSTRUCTURED).addChild("c", NT_OAK_UNSTRUCTURED);
n.addChild("aa", NT_OAK_UNSTRUCTURED).addChild("bb", NT_OAK_UNSTRUCTURED).addChild("cc", NT_OAK_UNSTRUCTURED);
// create cugs
createCug("/content/a", getTestUser().getPrincipal());
// setup regular acl at /content
AccessControlManager acMgr = getAccessControlManager(root);
AccessControlList acl = AccessControlUtils.getAccessControlList(acMgr, "/content");
acl.addAccessControlEntry(getTestUser().getPrincipal(), privilegesFromNames(PrivilegeConstants.JCR_READ));
acMgr.setPolicy("/content", acl);
root.commit();
}
Aggregations