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 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));
Iterator<? extends Principal> res2 = principalProvider.findPrincipals("a", false, PrincipalManager.SEARCH_TYPE_ALL, 0, -1);
assertTrue(res2.hasNext());
assertEquals(expected, ImmutableSet.copyOf(res2));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class LargeLdapProviderTest method testGetMembers.
@Test
public void testGetMembers() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(GROUP_DN, IDP_NAME);
ExternalIdentity id = idp.getIdentity(ref);
assertTrue("Group instance", id instanceof ExternalGroup);
ExternalGroup grp = (ExternalGroup) id;
assertIfEquals("Group members", TEST_MEMBERS, grp.getDeclaredMembers());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class LdapIdentityProviderTest method testGetDeclaredMembers.
@Test
public void testGetDeclaredMembers() throws Exception {
ExternalGroup gr = idp.getGroup(TEST_GROUP1_NAME);
Iterable<ExternalIdentityRef> memberrefs = gr.getDeclaredMembers();
Iterable<String> memberIds = Iterables.transform(memberrefs, externalIdentityRef -> externalIdentityRef.getId());
Set<String> expected = ImmutableSet.copyOf(TEST_GROUP1_MEMBERS);
assertEquals(expected, ImmutableSet.copyOf(memberIds));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup in project jackrabbit-oak by apache.
the class LdapIdentityProviderTest method testGetGroupByUnknownName.
@Test
public void testGetGroupByUnknownName() throws Exception {
ExternalGroup group = idp.getGroup("unknown");
assertNull(group);
}
Aggregations