use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testCreateSyncedIdentitySyncedGroup.
@Test
public void testCreateSyncedIdentitySyncedGroup() throws Exception {
ExternalIdentity externalGroup = idp.listGroups().next();
sync(externalGroup);
Authorizable a = userManager.getAuthorizable(externalGroup.getId());
SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(a);
assertNotNull(si);
assertEquals(a.getID(), si.getId());
assertNotNull(si.getExternalIdRef());
assertTrue(si.isGroup());
assertEquals(syncCtx.now, si.lastSynced());
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncHandlerTest method testRequiresSyncExpiredSyncProperty.
@Test
public void testRequiresSyncExpiredSyncProperty() throws Exception {
login(new SimpleCredentials(USER_ID, new char[0])).close();
root.refresh();
final Calendar nowCal = Calendar.getInstance();
nowCal.setTimeInMillis(nowCal.getTimeInMillis() - 1000);
Value nowValue = getValueFactory().createValue(nowCal);
Authorizable a = userManager.getAuthorizable(USER_ID);
a.setProperty(DefaultSyncContext.REP_LAST_SYNCED, nowValue);
root.commit();
SyncedIdentity id = syncHandler.findIdentity(userManager, USER_ID);
assertNotNull("known authorizable should exist", id);
assertTrue("synced id should require sync", syncHandler.requiresSync(id));
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncHandlerTest method testRequiresSyncMissingSyncProperty.
@Test
public void testRequiresSyncMissingSyncProperty() throws Exception {
sync(USER_ID, false);
Authorizable a = userManager.getAuthorizable(USER_ID);
a.removeProperty(DefaultSyncContext.REP_LAST_SYNCED);
root.commit();
SyncedIdentity si = syncHandler.findIdentity(userManager, USER_ID);
assertNotNull(si);
assertTrue(syncHandler.requiresSync(si));
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncPropertiesMappingConstants.
@Test
public void testSyncPropertiesMappingConstants() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_SECOND_USER);
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
// create mapping that doesn't match to names in the external-properties
// -> previously synced properties must be removed
Map<String, String> mapping = new HashMap();
Map<String, ?> extProps = externalUser.getProperties();
for (String propName : extProps.keySet()) {
mapping.put(propName, "\"any\"");
}
syncCtx.syncProperties(externalUser, a, mapping);
Value anyValue = valueFactory.createValue("any");
for (String propName : extProps.keySet()) {
assertTrue(a.hasProperty(propName));
assertEquals(anyValue, a.getProperty(propName)[0]);
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testCreateSyncedIdentitySyncedUser.
@Test
public void testCreateSyncedIdentitySyncedUser() throws Exception {
ExternalIdentity externalUser = idp.listUsers().next();
sync(externalUser);
Authorizable a = userManager.getAuthorizable(externalUser.getId());
SyncedIdentity si = DefaultSyncContext.createSyncedIdentity(a);
assertNotNull(si);
assertEquals(a.getID(), si.getId());
assertNotNull(si.getExternalIdRef());
assertFalse(si.isGroup());
assertEquals(syncCtx.now, si.lastSynced());
}
Aggregations