use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncUserException.
/**
* @see <a href="https://issues.apache.org/jira/browse/OAK-4360">OAK-4360</a>
*/
@Test
public void testSyncUserException() 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.syncUsers(new String[] { TestIdentityProvider.ID_EXCEPTION }, false);
assertResultMessages(result, TestIdentityProvider.ID_EXCEPTION, "ERR");
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testInitialSyncExternalGroup.
@Test
public void testInitialSyncExternalGroup() throws Exception {
ExternalGroup externalGroup = idp.getGroup("a");
String[] externalId = new String[] { externalGroup.getExternalId().getString() };
String[] result = syncMBean.syncExternalUsers(externalId);
assertResultMessages(result, "a", "add");
UserManager userManager = getUserManager();
Group aGroup = userManager.getAuthorizable(externalGroup.getId(), Group.class);
assertNotNull(aGroup);
// membership of groups are not synced (unless imposed by user-sync with membership depth)
for (ExternalIdentityRef groupRef : externalGroup.getDeclaredGroups()) {
assertNull(userManager.getAuthorizable(groupRef.getId()));
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncExternalUserThrowingHandler.
@Test
public void testSyncExternalUserThrowingHandler() throws Exception {
ExternalIdentityRef ref = new ExternalIdentityRef(TestIdentityProvider.ID_TEST_USER, idp.getName());
String[] result = createThrowingSyncMBean(false).syncExternalUsers(new String[] { ref.getString() });
assertResultMessages(result, TestIdentityProvider.ID_TEST_USER, "ERR");
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncExternalUsersLastSyncedProperty.
@Test
public void testSyncExternalUsersLastSyncedProperty() throws Exception {
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_TEST_USER);
String[] externalId = new String[] { externalUser.getExternalId().getString() };
syncMBean.syncExternalUsers(externalId);
UserManager userManager = getUserManager();
User testUser = userManager.getAuthorizable(externalUser.getId(), User.class);
long lastSynced = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) {
Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class);
long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue(lastSynced == groupLastSynced);
}
while (System.currentTimeMillis() <= lastSynced) {
// wait for system time to move
}
// default value for forceGroup sync is defined to be 'true' => verify result
syncMBean.syncExternalUsers(externalId);
userManager = getUserManager();
testUser = userManager.getAuthorizable(externalUser.getId(), User.class);
long lastSynced2 = testUser.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue("lastSynced: " + lastSynced + ", lastSynced2: " + lastSynced2, lastSynced < lastSynced2);
for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) {
Group gr = userManager.getAuthorizable(groupRef.getId(), Group.class);
long groupLastSynced = gr.getProperty(DefaultSyncContext.REP_LAST_SYNCED)[0].getLong();
assertTrue(lastSynced2 == groupLastSynced);
}
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testInitialSyncExternalUsersNoNesting.
@Test
public void testInitialSyncExternalUsersNoNesting() throws Exception {
syncConfig.user().setMembershipNestingDepth(-1);
ExternalUser externalUser = idp.getUser(TestIdentityProvider.ID_TEST_USER);
String[] externalId = new String[] { externalUser.getExternalId().getString() };
String[] result = syncMBean.syncExternalUsers(externalId);
assertResultMessages(result, TestIdentityProvider.ID_TEST_USER, "add");
UserManager userManager = getUserManager();
User testUser = userManager.getAuthorizable(externalUser.getId(), User.class);
assertNotNull(testUser);
for (ExternalIdentityRef groupRef : externalUser.getDeclaredGroups()) {
assertNull(userManager.getAuthorizable(groupRef.getId()));
}
}
Aggregations