use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncRemovedGroupById.
@Test
public void testSyncRemovedGroupById() throws Exception {
// mark a regular repo user as external user from the test IDP
Group gr = createTestGroup();
String groupId = gr.getID();
setExternalID(gr, idp.getName());
// test sync with 'keepmissing' = true
syncCtx.setKeepMissing(true);
SyncResult result = syncCtx.sync(groupId);
assertEquals(SyncResult.Status.MISSING, result.getStatus());
assertNotNull(userManager.getAuthorizable(groupId));
// test sync with 'keepmissing' = false
syncCtx.setKeepMissing(false);
result = syncCtx.sync(groupId);
assertEquals(SyncResult.Status.DELETE, result.getStatus());
assertNull(userManager.getAuthorizable(groupId));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncHandlerTest method sync.
private void sync(@Nonnull String id, boolean isGroup) throws Exception {
SyncContext ctx = syncHandler.createContext(idp, userManager, getValueFactory());
ExternalIdentity exIdentity = (isGroup) ? idp.getGroup(id) : idp.getUser(id);
assertNotNull(exIdentity);
SyncResult res = ctx.sync(exIdentity);
assertSame(SyncResult.Status.ADD, res.getStatus());
root.commit();
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncAutoMembership.
@Test
public void testSyncAutoMembership() throws Exception {
Group gr = createTestGroup();
syncConfig.user().setAutoMembership(gr.getID());
SyncResult result = syncCtx.sync(idp.listUsers().next());
assertEquals(SyncResult.Status.ADD, result.getStatus());
Authorizable a = userManager.getAuthorizable(result.getIdentity().getId());
assertTrue(gr.isDeclaredMember(a));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncUserById.
@Test
public void testSyncUserById() throws Exception {
ExternalIdentity externalId = idp.listUsers().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.setForceUserSync(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 testSyncDoesNotEnableUsers.
@Test
public void testSyncDoesNotEnableUsers() throws Exception {
// configure to remove missing users, check that sync does not mess with disabled status
syncConfig.user().setDisableMissing(false);
// test sync with 'keepmissing' = false
syncCtx.setKeepMissing(false);
ExternalUser user = idp.listUsers().next();
assertNotNull(user);
SyncResult result = syncCtx.sync(user);
assertEquals(SyncResult.Status.ADD, result.getStatus());
Authorizable authorizable = userManager.getAuthorizable(user.getId());
assertTrue(authorizable instanceof User);
User u = (User) authorizable;
// disable user
u.disable("disabled locally");
root.commit();
// sync
syncCtx.setForceUserSync(true);
result = syncCtx.sync(user.getId());
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
authorizable = userManager.getAuthorizable(user.getId());
assertNotNull(authorizable);
assertTrue(authorizable instanceof User);
assertTrue(((User) authorizable).isDisabled());
}
Aggregations