use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class AccessControlValidatorTest method testAddPolicyWithAcContent.
@Test
public void testAddPolicyWithAcContent() throws Exception {
NodeUtil acl = createAcl();
NodeUtil ace = acl.getChild(aceName);
NodeUtil[] acContent = new NodeUtil[] { acl, ace, ace.getChild(REP_RESTRICTIONS) };
for (NodeUtil node : acContent) {
NodeUtil policy = node.addChild(REP_POLICY, NT_REP_ACL);
try {
root.commit();
fail("Adding an ACL below access control content should fail");
} catch (CommitFailedException e) {
// success
assertTrue(e.isConstraintViolation());
assertThat(e.getMessage(), containsString("/testRoot/rep:policy"));
} finally {
policy.getTree().remove();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class AccessControlValidatorTest method testAddAceWithAcContent.
@Test
public void testAddAceWithAcContent() throws Exception {
NodeUtil acl = createAcl();
NodeUtil ace = acl.getChild(aceName);
NodeUtil[] acContent = new NodeUtil[] { ace, ace.getChild(REP_RESTRICTIONS) };
for (NodeUtil node : acContent) {
NodeUtil entry = node.addChild("invalidACE", NT_REP_DENY_ACE);
try {
root.commit();
fail("Adding an ACE below an ACE or restriction should fail");
} catch (CommitFailedException e) {
// success
assertTrue(e.isConstraintViolation());
assertThat(e.getMessage(), containsString("/testRoot/rep:policy/validAce"));
} finally {
entry.getTree().remove();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class AccessControlValidatorTest method testAddRestrictionWithAcContent.
@Test
public void testAddRestrictionWithAcContent() throws Exception {
NodeUtil acl = createAcl();
NodeUtil ace = acl.getChild(aceName);
NodeUtil[] acContent = new NodeUtil[] { acl, ace.getChild(REP_RESTRICTIONS) };
for (NodeUtil node : acContent) {
NodeUtil entry = node.addChild("invalidRestriction", NT_REP_RESTRICTIONS);
try {
root.commit();
fail("Adding an ACE below an ACE or restriction should fail");
} catch (CommitFailedException e) {
// success
assertTrue(e.isConstraintViolation());
assertThat(e.getMessage(), containsString("/testRoot/rep:policy"));
} finally {
entry.getTree().remove();
}
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class RepExternalIdTest method testUniqueConstraintNonUserNode.
@Test
public void testUniqueConstraintNonUserNode() throws Exception {
try {
SyncResult res = syncCtx.sync(idp.getUser(USER_ID));
Tree nonUserTree = r.getTree("/");
nonUserTree.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, res.getIdentity().getExternalIdRef().getString());
r.commit();
fail("Duplicate value for rep:externalId must be detected in the default setup.");
} catch (CommitFailedException e) {
// success: verify nature of the exception
assertTrue(e.isConstraintViolation());
assertEquals(30, e.getCode());
} finally {
r.refresh();
}
}
use of org.apache.jackrabbit.oak.api.CommitFailedException in project jackrabbit-oak by apache.
the class RepExternalIdTest method testUniqueConstraint.
@Test
public void testUniqueConstraint() throws Exception {
SyncResult res = syncCtx.sync(idp.getUser(USER_ID));
try {
Tree t = r.getTree(getTestUser().getPath());
t.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, res.getIdentity().getExternalIdRef().getString());
r.commit();
fail("Duplicate value for rep:externalId must be detected in the default setup.");
} catch (CommitFailedException e) {
// success: verify nature of the exception
assertTrue(e.isConstraintViolation());
assertEquals(30, e.getCode());
} finally {
r.refresh();
}
}
Aggregations