Search in sources :

Example 6 with SyncResult

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());
}
Also used : User(org.apache.jackrabbit.api.security.user.User) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) ExternalUser(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser) SyncedIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest) Test(org.junit.Test)

Example 7 with SyncResult

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));
}
Also used : SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) Test(org.junit.Test)

Example 8 with SyncResult

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"));
}
Also used : SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) Test(org.junit.Test)

Example 9 with SyncResult

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);
}
Also used : SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) Test(org.junit.Test) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)

Example 10 with SyncResult

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();
    }
}
Also used : Tree(org.apache.jackrabbit.oak.api.Tree) SyncResult(org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult) CommitFailedException(org.apache.jackrabbit.oak.api.CommitFailedException) Test(org.junit.Test) AbstractExternalAuthTest(org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)

Aggregations

SyncResult (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult)46 Test (org.junit.Test)37 AbstractExternalAuthTest (org.apache.jackrabbit.oak.spi.security.authentication.external.AbstractExternalAuthTest)34 ExternalGroup (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup)14 ExternalUser (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalUser)13 User (org.apache.jackrabbit.api.security.user.User)11 SyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncedIdentity)11 Group (org.apache.jackrabbit.api.security.user.Group)10 ExternalIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity)7 ExternalIdentityRef (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef)5 Nonnull (javax.annotation.Nonnull)4 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)4 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)4 Tree (org.apache.jackrabbit.oak.api.Tree)4 SyncContext (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncContext)4 ArrayList (java.util.ArrayList)3 DefaultSyncContext (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext)3 DefaultSyncedIdentity (org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncedIdentity)3 ExternalIdentityException (org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityException)2 SyncException (org.apache.jackrabbit.oak.spi.security.authentication.external.SyncException)2