use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncForeignExternalUser.
@Test
public void testSyncForeignExternalUser() throws Exception {
ExternalIdentity foreign = new TestIdentityProvider.ForeignExternalUser();
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);
assertFalse(si.isGroup());
assertEquals(-1, si.lastSynced());
assertFalse(root.hasPendingChanges());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncUserIdExistingGroups.
@Test
public void testSyncUserIdExistingGroups() throws Exception {
ExternalUser externalUser = idp.getUser(USER_ID);
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalUser);
ctx.close();
Authorizable user = userManager.getAuthorizable(externalUser.getId());
for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
Group gr = userManager.getAuthorizable(ref.getId(), Group.class);
assertTrue(gr.isMember(user));
}
syncContext.setForceUserSync(true);
syncContext.sync(externalUser.getId());
Authorizable a = userManager.getAuthorizable(USER_ID);
Tree t = r.getTree(a.getPath());
assertFalse(t.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES));
assertSyncedMembership(userManager, a, externalUser);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncExternalUserDepth1.
@Test
public void testSyncExternalUserDepth1() throws Exception {
syncConfig.user().setMembershipNestingDepth(1);
ExternalUser externalUser = idp.getUser(USER_ID);
sync(externalUser, SyncResult.Status.ADD);
Tree tree = r.getTree(userManager.getAuthorizable(USER_ID).getPath());
PropertyState extPrincipalNames = tree.getProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES);
assertNotNull(extPrincipalNames);
Set<String> pNames = Sets.newHashSet(extPrincipalNames.getValue(Type.STRINGS));
for (ExternalIdentityRef ref : externalUser.getDeclaredGroups()) {
assertTrue(pNames.remove(idp.getIdentity(ref).getPrincipalName()));
}
assertTrue(pNames.isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DefaultSyncHandlerTest method testListIdentitiesAfterSync.
@Test
public void testListIdentitiesAfterSync() throws Exception {
sync(USER_ID, false);
// membership-nesting is 1 => expect only 'USER_ID' plus the declared group-membership
Set<String> expected = Sets.newHashSet(USER_ID);
for (ExternalIdentityRef extRef : idp.getUser(USER_ID).getDeclaredGroups()) {
expected.add(extRef.getId());
}
Iterator<SyncedIdentity> identities = syncHandler.listIdentities(userManager);
while (identities.hasNext()) {
SyncedIdentity si = identities.next();
if (expected.contains(si.getId())) {
expected.remove(si.getId());
assertNotNull(si.getExternalIdRef());
} else {
fail("Sync handler returned unexpected identity: " + si);
}
}
assertTrue(expected.isEmpty());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DelegateeTest method testSyncForeignExternalUserSaveError.
@Test
public void testSyncForeignExternalUserSaveError() throws Exception {
Root r = preventRootCommit(delegatee);
;
String[] result = delegatee.syncExternalUsers(new String[] { new ExternalIdentityRef(TestIdentityProvider.ID_TEST_USER, foreignIDP.getName()).getString() });
assertResultMessages(result, TestIdentityProvider.ID_TEST_USER, "for");
assertFalse(r.hasPendingChanges());
}
Aggregations