DefaultSyncContext implements SyncContext { protected boolean isSameIDP(@Nullable Authorizable auth) throws RepositoryException { ExternalIdentityRef ref = getIdentityRef(auth); return ref != null && idp.getName().equals(ref.getProviderName()); } DefaultSyncContext(@NotNull DefaultSyncConfig config, @NotNull ExternalIdentityProvider idp, @NotNull UserManager userManager, @NotNull ValueFactory valueFactory); @Nullable static DefaultSyncedIdentity createSyncedIdentity(@Nullable Authorizable auth); @Nullable static ExternalIdentityRef getIdentityRef(@Nullable Authorizable auth); static String joinPaths(String... paths); @Override void close(); @Override boolean isKeepMissing(); @NotNull @Override SyncContext setKeepMissing(boolean keepMissing); @Override boolean isForceUserSync(); @NotNull @Override SyncContext setForceUserSync(boolean forceUserSync); @Override boolean isForceGroupSync(); @Override @NotNull SyncContext setForceGroupSync(boolean forceGroupSync); @NotNull @Override SyncResult sync(@NotNull ExternalIdentity identity); @NotNull @Override SyncResult sync(@NotNull String id); static final String REP_EXTERNAL_ID; static final String REP_LAST_SYNCED; }
@Test public void testIsSameIDPNull() throws Exception { assertFalse(syncCtx.isSameIDP((Authorizable) null)); }
@Test public void testIsSameIDPLocalGroup() throws Exception { assertFalse(syncCtx.isSameIDP(createTestGroup())); }
@Test public void testIsSameIDPLocalUser() throws Exception { assertFalse(syncCtx.isSameIDP(getTestUser())); }
@Test public void testIsSameIDPExternalIdentityRef() throws Exception { assertFalse(syncCtx.isSameIDP(new TestIdentityProvider.ForeignExternalUser().getExternalId())); assertFalse(syncCtx.isSameIDP(new TestIdentityProvider.ForeignExternalGroup().getExternalId())); assertTrue(syncCtx.isSameIDP(new TestIdentityProvider.TestIdentity().getExternalId())); assertTrue(syncCtx.isSameIDP(idp.listGroups().next().getExternalId())); assertTrue(syncCtx.isSameIDP(idp.listUsers().next().getExternalId())); }