use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncMembershipWithChangedExistingGroups.
@Test
public void testSyncMembershipWithChangedExistingGroups() throws Exception {
long nesting = 1;
syncConfig.user().setMembershipNestingDepth(nesting);
ExternalUser externalUser = idp.getUser(USER_ID);
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalUser);
ctx.close();
Authorizable a = userManager.getAuthorizable(externalUser.getId());
assertSyncedMembership(userManager, a, externalUser);
// sync user with modified membership => must be reflected
// 1. empty set of declared groups
ExternalUser mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of());
syncContext.syncMembership(mod, a, nesting);
assertSyncedMembership(userManager, a, mod);
// 2. set with different groups that defined on IDP
mod = new TestUserWithGroupRefs(externalUser, ImmutableSet.<ExternalIdentityRef>of(idp.getGroup("a").getExternalId(), idp.getGroup("aa").getExternalId(), idp.getGroup("secondGroup").getExternalId()));
syncContext.syncMembership(mod, a, nesting);
assertSyncedMembership(userManager, a, mod);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class ExternalGroupPrincipalProviderTest method testGetPrincipalInheritedGroups.
@Test
public void testGetPrincipalInheritedGroups() throws Exception {
ImmutableSet<ExternalIdentityRef> declared = ImmutableSet.<ExternalIdentityRef>copyOf(idp.getUser(USER_ID).getDeclaredGroups());
for (ExternalIdentityRef ref : declared) {
for (ExternalIdentityRef inheritedGroupRef : idp.getIdentity(ref).getDeclaredGroups()) {
if (declared.contains(inheritedGroupRef)) {
continue;
}
String inheritedPrincName = idp.getIdentity(inheritedGroupRef).getPrincipalName();
assertNull(principalProvider.getPrincipal(inheritedPrincName));
}
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncExternalLocal.
/**
* @see <a href="https://issues.apache.org/jira/browse/OAK-4346">OAK-4346</a>
*/
@Test
public void testSyncExternalLocal() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(UserConstants.DEFAULT_ANONYMOUS_ID, null);
String[] result = syncMBean.syncExternalUsers(new String[] { ref.getString() });
assertResultMessages(result, UserConstants.DEFAULT_ANONYMOUS_ID, "for");
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncExternalNonExisting.
@Test
public void testSyncExternalNonExisting() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef("nonExisting", idp.getName());
String[] result = syncMBean.syncExternalUsers(new String[] { ref.getString() });
assertResultMessages(result, "", "nsi");
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testPurgeOrphanedUsersException.
@Test
public void testPurgeOrphanedUsersException() throws Exception {
User u = getUserManager().createUser(TestIdentityProvider.ID_EXCEPTION, null);
u.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, getValueFactory().createValue(new ExternalIdentityRef(TestIdentityProvider.ID_EXCEPTION, idp.getName()).getString()));
root.commit();
String[] result = syncMBean.purgeOrphanedUsers();
assertEquals(0, result.length);
}
Aggregations