use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testIsExpiredSyncedUser.
@Test
public void testIsExpiredSyncedUser() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
assertFalse(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
assertTrue(syncCtx.isExpired(a, -1, "any"));
// create a ctx with a newer 'now'
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
long expTime = ctx.now - syncCtx.now - 1;
assertTrue(ctx.isExpired(a, expTime, "any"));
// remove last-sync property
a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED);
assertTrue(syncCtx.isExpired(a, syncConfig.user().getExpirationTime(), "any"));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testGetIdentityRefSyncUser.
@Test
public void testGetIdentityRefSyncUser() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
ExternalIdentityRef ref = DefaultSyncContext.getIdentityRef(userManager.getAuthorizable(externalUser.getId()));
assertNotNull(ref);
assertEquals(externalUser.getExternalId(), ref);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method collectExpectedPrincipals.
private void collectExpectedPrincipals(Set<Principal> grPrincipals, @Nonnull Iterable<ExternalIdentityRef> declaredGroups, long depth) throws Exception {
if (depth <= 0) {
return;
}
for (ExternalIdentityRef ref : declaredGroups) {
ExternalIdentity ei = idp.getIdentity(ref);
grPrincipals.add(new PrincipalImpl(ei.getPrincipalName()));
collectExpectedPrincipals(grPrincipals, ei.getDeclaredGroups(), depth - 1);
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncAllUsers.
@Test
public void testSyncAllUsers() throws Exception {
// first sync external users into the repo
syncMBean.syncAllExternalUsers();
// verify effect of syncAllUsers
String[] result = syncMBean.syncAllUsers(false);
Map<String, String> expected = getExpectedUserResult("upd", true);
assertResultMessages(result, expected);
UserManager userManager = getUserManager();
for (String id : expected.keySet()) {
ExternalIdentity ei = idp.getUser(id);
if (ei == null) {
ei = idp.getGroup(id);
}
assertSync(ei, userManager);
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncAllExternalUsersAgain.
@Test
public void testSyncAllExternalUsersAgain() throws Exception {
syncMBean.syncAllExternalUsers();
// sync again
String[] result = syncMBean.syncAllExternalUsers();
// verify result
Map<String, String> expected = getExpectedUserResult("upd", false);
assertResultMessages(result, expected);
UserManager userManager = getUserManager();
for (String id : expected.keySet()) {
ExternalIdentity ei = idp.getUser(id);
if (ei == null) {
ei = idp.getGroup(id);
}
assertSync(ei, userManager);
}
}
Aggregations