use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugContextTest method testInvalidCug.
@Test
public void testInvalidCug() throws Exception {
PropertyState ps = PropertyStates.createProperty(CugConstants.REP_PRINCIPAL_NAMES, ImmutableSet.of(getTestUser().getPrincipal().getName()), Type.STRINGS);
// cug at unsupported path -> context doesn't take supported paths into account.
Tree invalidCug = new NodeUtil(root.getTree(UNSUPPORTED_PATH)).addChild(CugConstants.REP_CUG_POLICY, CugConstants.NT_REP_CUG_POLICY).getTree();
invalidCug.setProperty(ps);
assertTrue(CugContext.INSTANCE.definesContextRoot(invalidCug));
assertTrue(CugContext.INSTANCE.definesTree(invalidCug));
assertTrue(CugContext.INSTANCE.definesProperty(invalidCug, invalidCug.getProperty(CugConstants.REP_PRINCIPAL_NAMES)));
// 'cug' with wrong node type -> detected as no-cug by context
invalidCug = new NodeUtil(root.getTree(UNSUPPORTED_PATH)).addChild(CugConstants.REP_CUG_POLICY, NT_OAK_UNSTRUCTURED).getTree();
invalidCug.setProperty(ps);
assertFalse(CugContext.INSTANCE.definesContextRoot(invalidCug));
assertFalse(CugContext.INSTANCE.definesTree(invalidCug));
assertFalse(CugContext.INSTANCE.definesProperty(invalidCug, invalidCug.getProperty(CugConstants.REP_PRINCIPAL_NAMES)));
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugTreePermissionTest method testIsInCugSupportedPathWithoutCug.
@Test
public void testIsInCugSupportedPathWithoutCug() throws Exception {
NodeUtil node = new NodeUtil(root.getTree(SUPPORTED_PATH2));
Tree c1 = node.addChild("c1", NT_OAK_UNSTRUCTURED).getTree();
Tree c2 = node.addChild("c2", NT_OAK_UNSTRUCTURED).getTree();
String cugPath = c2.getPath();
createCug(cugPath, getTestGroupPrincipal());
root.commit();
assertTrue(getCugTreePermission(cugPath).isInCug());
assertFalse(getCugTreePermission(c1.getPath()).isInCug());
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CugAccessControlManagerTest method testSetInvalidCugNode.
@Test(expected = AccessControlException.class)
public void testSetInvalidCugNode() throws Exception {
Tree supportedTree = root.getTree(SUPPORTED_PATH);
new NodeUtil(supportedTree).addChild(REP_CUG_POLICY, NodeTypeConstants.NT_OAK_UNSTRUCTURED);
cugAccessControlManager.setPolicy(SUPPORTED_PATH, new CugPolicyImpl(SUPPORTED_PATH, NamePathMapper.DEFAULT, getPrincipalManager(root), ImportBehavior.BESTEFFORT));
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class CompositeTreePermissionTest method before.
@Override
public void before() throws Exception {
super.before();
NodeUtil rootNode = new NodeUtil(root.getTree("/"));
rootNode.addChild("test", NodeTypeConstants.NT_OAK_UNSTRUCTURED);
root.commit();
readOnlyRoot = RootFactory.createReadOnlyRoot(root);
rootTree = (ImmutableTree) readOnlyRoot.getTree("/");
fullScopeProvider = new FullScopeProvider(readOnlyRoot);
}
use of org.apache.jackrabbit.oak.util.NodeUtil in project jackrabbit-oak by apache.
the class JcrUUIDTest method before.
@Before
public void before() throws Exception {
super.before();
ntMgr = new ReadWriteNodeTypeManager() {
@Nonnull
@Override
protected Root getWriteRoot() {
return root;
}
@Override
protected Tree getTypes() {
return root.getTree(NODE_TYPES_PATH);
}
};
if (!ntMgr.hasNodeType(NT_NAME)) {
NodeTypeTemplate tmpl = ntMgr.createNodeTypeTemplate();
tmpl.setName(NT_NAME);
tmpl.setDeclaredSuperTypeNames(new String[] { JcrConstants.MIX_REFERENCEABLE, JcrConstants.NT_UNSTRUCTURED });
ntMgr.registerNodeType(tmpl, true);
}
NodeUtil a = new NodeUtil(root.getTree("/a"));
NodeUtil test = a.addChild("referenceable", NT_NAME);
test.setString(JcrConstants.JCR_UUID, IdentifierManager.generateUUID());
referenceablePath = test.getTree().getPath();
}
Aggregations