use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testLostMembershipWithExpirationSet.
@Test
public void testLostMembershipWithExpirationSet() throws Exception {
long expTime = 2;
syncConfig.user().setMembershipNestingDepth(1).setMembershipExpirationTime(expTime).setExpirationTime(expTime);
Group gr = createTestGroup();
setExternalID(gr, idp.getName());
SyncResult result = syncCtx.sync(idp.listUsers().next());
User user = (User) userManager.getAuthorizable(result.getIdentity().getId());
gr.addMember(user);
root.commit();
waitUntilExpired(user, root, expTime);
DefaultSyncContext newCtx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
result = newCtx.sync(user.getID());
root.commit();
assertSame(SyncResult.Status.UPDATE, result.getStatus());
gr = (Group) userManager.getAuthorizable(gr.getID());
assertFalse(gr.isDeclaredMember(userManager.getAuthorizable(user.getID())));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testLostMembership.
@Test
public void testLostMembership() throws Exception {
// create a group in the repository which is marked as being external
// and associated with the test-IDP to setup the situation that a
// repository group is no longer listed in the IDP.
Group gr = createTestGroup();
setExternalID(gr, idp.getName());
// sync an external user from the IDP into the repo and make it member
// of the test group
SyncResult result = syncCtx.sync(idp.listUsers().next());
User user = userManager.getAuthorizable(result.getIdentity().getId(), User.class);
gr.addMember(user);
root.commit();
// enforce synchronization of the user and it's group membership
syncCtx.setForceUserSync(true);
syncConfig.user().setMembershipExpirationTime(-1);
// 1. membership nesting is < 0 => membership not synchronized
syncConfig.user().setMembershipNestingDepth(-1);
syncCtx.sync(user.getID()).getStatus();
assertTrue(gr.isDeclaredMember(user));
// 2. membership nesting is > 0 => membership gets synchronized
syncConfig.user().setMembershipNestingDepth(1);
assertEquals(SyncResult.Status.UPDATE, syncCtx.sync(user.getID()).getStatus());
assertFalse(gr.isDeclaredMember(user));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncUserByIdUpdate.
@Test
public void testSyncUserByIdUpdate() throws Exception {
ExternalIdentity externalId = idp.listUsers().next();
Authorizable a = userManager.createUser(externalId.getId(), null);
a.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, valueFactory.createValue(externalId.getExternalId().getString()));
syncContext.setForceUserSync(true);
SyncResult result = syncContext.sync(externalId.getId());
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
Tree t = r.getTree(a.getPath());
assertTrue(t.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncByForeignGroupId.
@Test
public void testSyncByForeignGroupId() throws Exception {
SyncResult result = syncCtx.sync(createTestGroup().getID());
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertNull(si.getExternalIdRef());
assertTrue(si.isGroup());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncResultImplTest method testGetIdentityFromNull.
@Test
public void testGetIdentityFromNull() {
SyncResult res = new DefaultSyncResultImpl(null, SyncResult.Status.NOP);
assertNull(res.getIdentity());
}
Aggregations