use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncAllGroups.
@Test
public void testSyncAllGroups() throws Exception {
// first sync external users into the repo
Map<String, String> expected = new HashMap();
Iterator<ExternalGroup> grIt = idp.listGroups();
while (grIt.hasNext()) {
ExternalGroup eg = grIt.next();
sync(idp, eg.getId(), true);
expected.put(eg.getId(), "upd");
}
// verify effect of syncAllUsers (which in this case are groups)
String[] result = syncMBean.syncAllUsers(false);
assertResultMessages(result, expected);
UserManager userManager = getUserManager();
for (String id : expected.keySet()) {
ExternalIdentity ei = idp.getGroup(id);
assertSync(ei, userManager);
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncForeignExternalGroup.
@Test
public void testSyncForeignExternalGroup() throws Exception {
ExternalGroup foreign = new TestIdentityProvider.ForeignExternalGroup();
SyncResult res = syncContext.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);
assertTrue(si.isGroup());
assertEquals(-1, si.lastSynced());
assertFalse(r.hasPendingChanges());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncExternalGroupExisting.
@Test
public void testSyncExternalGroupExisting() throws Exception {
// create an external external group that already has been synced into the repo
ExternalGroup externalGroup = idp.listGroups().next();
SyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalGroup);
ctx.close();
// synchronizing using DynamicSyncContext must update the existing group
syncContext.setForceGroupSync(true);
SyncResult result = syncContext.sync(externalGroup);
assertSame(SyncResult.Status.UPDATE, result.getStatus());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testFindPrincipalsFiltersDuplicates.
@Test
public void testFindPrincipalsFiltersDuplicates() throws Exception {
ExternalGroup gr = idp.getGroup("a");
ExternalUser otherUser = new TestUser("anotherUser", ImmutableSet.of(gr.getExternalId()));
sync(otherUser);
Set<Principal> expected = new HashSet();
expected.add(new PrincipalImpl(gr.getPrincipalName()));
long depth = syncConfig.user().getMembershipNestingDepth();
if (depth > 1) {
collectExpectedPrincipals(expected, gr.getDeclaredGroups(), --depth);
}
Iterator<? extends Principal> res = principalProvider.findPrincipals("a", PrincipalManager.SEARCH_TYPE_ALL);
assertTrue(res.hasNext());
assertEquals(expected, ImmutableSet.copyOf(res));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class LdapProviderTest method testGetMembers.
@Test
public void testGetMembers() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TEST_GROUP1_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("Group instance", id instanceof ExternalGroup);
ExternalGroup grp = (ExternalGroup) id;
assertIfEquals("Group members", TEST_GROUP1_MEMBERS, grp.getDeclaredMembers());
}
Aggregations