use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncMembershipDepthInfinite.
@Test
public void testSyncMembershipDepthInfinite() throws Exception {
ExternalUser externalUser = idp.listUsers().next();
Authorizable a = syncCtx.createUser(externalUser);
syncCtx.syncMembership(externalUser, a, Long.MAX_VALUE);
assertTrue(root.hasPendingChanges());
root.commit();
for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
ExternalIdentity extGr = idp.getIdentity(ref);
assertNotNull(extGr);
for (ExternalIdentityRef inheritedGrRef : extGr.getDeclaredGroups()) {
Group g = userManager.getAuthorizable(inheritedGrRef.getId(), Group.class);
assertNotNull(g);
if (Iterables.contains(externalUser.getDeclaredGroups(), inheritedGrRef)) {
assertTrue(g.isDeclaredMember(a));
} else {
assertFalse(g.isDeclaredMember(a));
}
assertTrue(g.isMember(a));
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testIsSameIDPMissingExternalId.
@Test
public void testIsSameIDPMissingExternalId() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
a.removeProperty(DefaultSyncContext.REP_EXTERNAL_ID);
assertFalse(syncCtx.isSameIDP(a));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncMembershipGroupIsExternalUser.
@Test
public void testSyncMembershipGroupIsExternalUser() throws Exception {
// sync the 'wrong' external group into the repository
ExternalIdentity externalIdentity = idp.listUsers().next();
sync(externalIdentity);
// create external user with an synced-ext-user as declared group
ExternalUser withWrongDeclaredGroup = new ExternalUserWithDeclaredGroup(externalIdentity.getExternalId());
try {
Authorizable a = syncCtx.createUser(withWrongDeclaredGroup);
root.commit();
syncCtx.syncMembership(withWrongDeclaredGroup, a, 1);
assertFalse(root.hasPendingChanges());
} finally {
Authorizable a = userManager.getAuthorizable(withWrongDeclaredGroup.getId());
if (a != null) {
a.remove();
root.commit();
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity 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.ExternalIdentity in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method collectGroupPrincipals.
private void collectGroupPrincipals(Set<String> pNames, @Nonnull Iterable<ExternalIdentityRef> declaredGroups, long depth) throws ExternalIdentityException {
if (depth <= 0) {
return;
}
for (ExternalIdentityRef ref : declaredGroups) {
ExternalIdentity ei = idp.getIdentity(ref);
pNames.add(ei.getPrincipalName());
collectGroupPrincipals(pNames, ei.getDeclaredGroups(), depth - 1);
}
}
Aggregations