use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class DefaultSyncContextTest method testSyncExternalForeignLocalUser.
@Test
public void testSyncExternalForeignLocalUser() throws Exception {
ExternalUser external = idp.listUsers().next();
syncCtx.sync(external);
User u = userManager.getAuthorizable(external.getId(), User.class);
setExternalID(u, "differentIDP");
SyncResult result = syncCtx.sync(external);
assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
SyncedIdentity si = result.getIdentity();
assertNotNull(si);
assertEquals(external.getExternalId(), si.getExternalIdRef());
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncUsersForeign.
@Test
public void testSyncUsersForeign() throws Exception {
// sync user from foreign IDP into the repository
SyncResult res = sync(foreignIDP, TestIdentityProvider.ID_TEST_USER, false);
assertNotNull(getUserManager().getAuthorizable(TestIdentityProvider.ID_TEST_USER));
assertEquals(foreignIDP.getUser(TestIdentityProvider.ID_TEST_USER).getExternalId(), res.getIdentity().getExternalIdRef());
// syncUsers with testIDP must detect the foreign status
String[] result = syncMBean.syncUsers(new String[] { TestIdentityProvider.ID_TEST_USER }, false);
assertResultMessages(result, TestIdentityProvider.ID_TEST_USER, "for");
assertNotNull(getUserManager().getAuthorizable(TestIdentityProvider.ID_TEST_USER));
// same expected with 'purge' set to true
result = syncMBean.syncUsers(new String[] { TestIdentityProvider.ID_TEST_USER }, true);
assertResultMessages(result, TestIdentityProvider.ID_TEST_USER, "for");
assertNotNull(getUserManager().getAuthorizable(TestIdentityProvider.ID_TEST_USER));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class SyncMBeanImplTest method testSyncGroupsForeign.
@Test
public void testSyncGroupsForeign() throws Exception {
// sync user from foreign IDP into the repository
SyncResult res = sync(foreignIDP, "a", true);
assertNotNull(getUserManager().getAuthorizable("a"));
assertEquals(foreignIDP.getGroup("a").getExternalId(), res.getIdentity().getExternalIdRef());
// syncUsers with testIDP must detect the foreign status
String[] result = syncMBean.syncUsers(new String[] { "a" }, false);
assertResultMessages(result, "a", "for");
assertNotNull(getUserManager().getAuthorizable("a"));
// same expected with 'purge' set to true
result = syncMBean.syncUsers(new String[] { "a" }, true);
assertResultMessages(result, "a", "for");
assertNotNull(getUserManager().getAuthorizable("a"));
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class RepExternalIdTest method syncExternalUser.
@Test
public void syncExternalUser() throws Exception {
SyncResult res = syncCtx.sync(idp.getUser(USER_ID));
assertRepExternalId(res);
}
use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.
the class RepExternalIdTest method testUniqueConstraintNonUserNode.
@Test
public void testUniqueConstraintNonUserNode() throws Exception {
try {
SyncResult res = syncCtx.sync(idp.getUser(USER_ID));
Tree nonUserTree = r.getTree("/");
nonUserTree.setProperty(DefaultSyncContext.REP_EXTERNAL_ID, res.getIdentity().getExternalIdRef().getString());
r.commit();
fail("Duplicate value for rep:externalId must be detected in the default setup.");
} catch (CommitFailedException e) {
// success: verify nature of the exception
assertTrue(e.isConstraintViolation());
assertEquals(30, e.getCode());
} finally {
r.refresh();
}
}
Aggregations