use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncByForeignUserId.
@Test
public void testSyncByForeignUserId() throws Exception {
SyncResult result = syncCtx.sync(getTestUser().getID());
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertNull(si.getExternalIdRef());
assertFalse(si.isGroup());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncDisabledUserById.
@Test
public void testSyncDisabledUserById() throws Exception {
// configure to disable missing users
syncConfig.user().setDisableMissing(true);
// mark a regular repo user as external user from the test IDP
User u = userManager.createUser("test" + UUID.randomUUID(), null);
String userId = u.getID();
setExternalID(u, idp.getName());
// test sync with 'keepmissing' = true
syncCtx.setKeepMissing(true);
SyncResult result = syncCtx.sync(userId);
assertEquals(SyncResult.Status.MISSING, result.getStatus());
assertNotNull(userManager.getAuthorizable(userId));
// test sync with 'keepmissing' = false
syncCtx.setKeepMissing(false);
result = syncCtx.sync(userId);
assertEquals(SyncResult.Status.DISABLE, result.getStatus());
Authorizable authorizable = userManager.getAuthorizable(userId);
assertNotNull(authorizable);
assertTrue(((User) authorizable).isDisabled());
// add external user back
addIDPUser(userId);
result = syncCtx.sync(userId);
assertEquals(SyncResult.Status.ENABLE, result.getStatus());
assertNotNull(userManager.getAuthorizable(userId));
assertFalse(((User) authorizable).isDisabled());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncForeignExternalGroup.
@Test
public void testSyncForeignExternalGroup() throws Exception {
ExternalIdentity foreign = new TestIdentityProvider.ForeignExternalGroup();
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);
assertTrue(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 testSyncGroupById.
@Test
public void testSyncGroupById() throws Exception {
ExternalIdentity externalId = idp.listGroups().next();
// no initial sync -> sync-by-id doesn't succeed
SyncResult result = syncCtx.sync(externalId.getId());
assertEquals(SyncResult.Status.NO_SUCH_AUTHORIZABLE, result.getStatus());
// force sync
syncCtx.sync(externalId);
// try again
syncCtx.setForceGroupSync(true);
result = syncCtx.sync(externalId.getId());
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalGroup.
@Test
public void testSyncExternalGroup() throws Exception {
ExternalGroup gr = idp.listGroups().next();
assertNotNull(gr);
SyncResult result = syncCtx.sync(gr);
assertEquals(SyncResult.Status.ADD, result.getStatus());
result = syncCtx.sync(gr);
assertEquals(SyncResult.Status.NOP, result.getStatus());
syncCtx.setForceGroupSync(true);
result = syncCtx.sync(gr);
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
}
Aggregations