Search in sources :

Example 11 with SyncResult

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.

the class RepExternalIdTest method syncExternalGroup.

@Test
public void syncExternalGroup() throws Exception {
    SyncResult res = syncCtx.sync(idp.listGroups().next());
    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 12 with SyncResult

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.

the class RepExternalIdTest method testUniqueConstraint.

@Test
public void testUniqueConstraint() throws Exception {
    SyncResult res = syncCtx.sync(idp.getUser(USER_ID));
    try {
        Tree t = r.getTree(getTestUser().getPath());
        t.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)

Example 13 with SyncResult

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testSyncForeignExternalUser.

@Test
public void testSyncForeignExternalUser() throws Exception {
    ExternalIdentity foreign = new TestIdentityProvider.ForeignExternalUser();
    SyncResult res = syncCtx.sync(foreign);
    assertNotNull(res);
    assertSame(SyncResult.Status.FOREIGN, res.getStatus());
    // expect {@code SyncedIdentity} in accordance with {@code sync(String userId)},
    // where the authorizable is found to be linked to a different IDP.
    SyncedIdentity si = res.getIdentity();
    assertNotNull(si);
    assertEquals(foreign.getId(), si.getId());
    ExternalIdentityRef ref = si.getExternalIdRef();
    assertNotNull(ref);
    assertEquals(foreign.getExternalId(), ref);
    assertFalse(si.isGroup());
    assertEquals(-1, si.lastSynced());
    assertFalse(root.hasPendingChanges());
}
Also used : ExternalIdentityRef(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentityRef) ExternalIdentity(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalIdentity) 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 14 with SyncResult

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testSyncExternalToForeignLocalGroup.

@Test
public void testSyncExternalToForeignLocalGroup() throws Exception {
    ExternalGroup external = idp.listGroups().next();
    syncCtx.sync(external);
    Group gr = userManager.getAuthorizable(external.getId(), Group.class);
    setExternalID(gr, "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 : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) 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 15 with SyncResult

use of org.apache.jackrabbit.oak.spi.security.authentication.external.SyncResult in project jackrabbit-oak by apache.

the class DefaultSyncContextTest method testSyncExternalToExistingLocalGroup.

@Test
public void testSyncExternalToExistingLocalGroup() throws Exception {
    ExternalGroup external = idp.listGroups().next();
    syncCtx.sync(external);
    Group gr = userManager.getAuthorizable(external.getId(), Group.class);
    gr.removeProperty(ExternalIdentityConstants.REP_EXTERNAL_ID);
    SyncResult result = syncCtx.sync(external);
    assertEquals(SyncResult.Status.FOREIGN, result.getStatus());
    SyncedIdentity si = result.getIdentity();
    assertNotNull(si);
    assertEquals(external.getExternalId(), si.getExternalIdRef());
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) ExternalGroup(org.apache.jackrabbit.oak.spi.security.authentication.external.ExternalGroup) 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)

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