use of org.apache.jackrabbit.api.security.user.Authorizable 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.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DynamicSyncContextTest method testSyncExternalUserExistingGroups.
@Test
public void testSyncExternalUserExistingGroups() throws Exception {
syncConfig.user().setMembershipNestingDepth(1);
ExternalUser externalUser = idp.getUser(USER_ID);
DefaultSyncContext ctx = new DefaultSyncContext(syncConfig, idp, userManager, valueFactory);
ctx.sync(externalUser);
ctx.close();
Authorizable a = userManager.getAuthorizable(USER_ID);
assertSyncedMembership(userManager, a, externalUser);
syncContext.setForceUserSync(true);
syncConfig.user().setMembershipExpirationTime(-1);
syncContext.sync(externalUser);
Tree t = r.getTree(a.getPath());
assertFalse(t.hasProperty(ExternalIdentityConstants.REP_EXTERNAL_PRINCIPAL_NAMES));
assertSyncedMembership(userManager, a, externalUser);
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncAutoMembership.
@Test
public void testSyncAutoMembership() throws Exception {
Group gr = createTestGroup();
syncConfig.user().setAutoMembership(gr.getID());
SyncResult result = syncCtx.sync(idp.listUsers().next());
assertEquals(SyncResult.Status.ADD, result.getStatus());
Authorizable a = userManager.getAuthorizable(result.getIdentity().getId());
assertTrue(gr.isDeclaredMember(a));
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncDoesNotEnableUsers.
@Test
public void testSyncDoesNotEnableUsers() throws Exception {
// configure to remove missing users, check that sync does not mess with disabled status
syncConfig.user().setDisableMissing(false);
// test sync with 'keepmissing' = false
syncCtx.setKeepMissing(false);
ExternalUser user = idp.listUsers().next();
assertNotNull(user);
SyncResult result = syncCtx.sync(user);
assertEquals(SyncResult.Status.ADD, result.getStatus());
Authorizable authorizable = userManager.getAuthorizable(user.getId());
assertTrue(authorizable instanceof User);
User u = (User) authorizable;
// disable user
u.disable("disabled locally");
root.commit();
// sync
syncCtx.setForceUserSync(true);
result = syncCtx.sync(user.getId());
assertEquals(SyncResult.Status.UPDATE, result.getStatus());
authorizable = userManager.getAuthorizable(user.getId());
assertNotNull(authorizable);
assertTrue(authorizable instanceof User);
assertTrue(((User) authorizable).isDisabled());
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesEmptyMapExistingProps.
@Test
public void testSyncPropertiesEmptyMapExistingProps() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
Authorizable a = syncCtx.createUser(externalUser);
Value anyValue = valueFactory.createValue("any");
Map<String, ?> extProps = externalUser.getProperties();
for (String propName : extProps.keySet()) {
a.setProperty(propName, anyValue);
}
syncCtx.syncProperties(externalUser, a, ImmutableMap.<String, String>of());
for (String propName : extProps.keySet()) {
assertTrue(a.hasProperty(propName));
assertEquals(anyValue, a.getProperty(propName)[0]);
}
}
Aggregations