use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class RepExternalIdTest method syncExternalGroup.
@Test
public void syncExternalGroup() throws Exception {
SyncResult res = syncCtx.sync(idp.listGroups().next());
assertRepExternalId(res);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult 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();
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncForeignExternalUser.
@Test
public void testSyncForeignExternalUser() throws Exception {
ExternalIdentity foreign = new TestIdentityProvider.ForeignExternalUser();
SyncResult res = syncCtx.sync(foreign);
assertNotNull(res);
assertSame(SyncResult.Status.FOREIGN, res.getStatus());
// expect {@code SyncedIdentity} in accordance with {@code sync(String userId)},
// where the authorizable is found to be linked to a different IDP.
SyncedIdentity si = res.getIdentity();
assertNotNull(si);
assertEquals(foreign.getId(), si.getId());
ExternalIdentityRef ref = si.getExternalIdRef();
assertNotNull(ref);
assertEquals(foreign.getExternalId(), ref);
assertFalse(si.isGroup());
assertEquals(-1, si.lastSynced());
assertFalse(root.hasPendingChanges());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalToForeignLocalGroup.
@Test
public void testSyncExternalToForeignLocalGroup() throws Exception {
ExternalGroup external = idp.listGroups().next();
syncCtx.sync(external);
Group gr = userManager.getAuthorizable(external.getId(), Group.class);
setExternalID(gr, "differentIDP");
SyncResult result = syncCtx.sync(external);
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertEquals(external.getExternalId(), si.getExternalIdRef());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalToExistingLocalGroup.
@Test
public void testSyncExternalToExistingLocalGroup() throws Exception {
ExternalGroup external = idp.listGroups().next();
syncCtx.sync(external);
Group gr = userManager.getAuthorizable(external.getId(), Group.class);
gr.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
SyncResult result = syncCtx.sync(external);
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertEquals(external.getExternalId(), si.getExternalIdRef());
}
Aggregations