use of org.apache.jackrabbit.oak.spi.security.authentication.external.basic.DefaultSyncContext in project jackrabbit-oak by apache.
the class PreAuthDefaultExternalLoginModuleTest method testExistingExternalReSync.
@Test
public void testExistingExternalReSync() throws Exception {
// sync user upfront
UserManager uMgr = getUserManager(root);
SyncContext syncContext = new DefaultSyncContext(syncConfig, idp, uMgr, getValueFactory(root));
SyncResult result = syncContext.sync(idp.getUser(TestIdentityProvider.ID_TEST_USER));
long lastSynced = result.getIdentity().lastSynced();
root.commit();
PreAuthCredentials creds = new PreAuthCredentials(TestIdentityProvider.ID_TEST_USER);
ContentSession cs = null;
try {
// wait until the synced user is expired
waitUntilExpired(uMgr.getAuthorizable(TestIdentityProvider.ID_TEST_USER, User.class), root, syncConfig.user().getExpirationTime());
cs = login(creds);
assertEquals(PreAuthCredentials.PRE_AUTH_DONE, creds.getMessage());
assertEquals(TestIdentityProvider.ID_TEST_USER, cs.getAuthInfo().getUserID());
root.refresh();
User u = getUserManager(root).getAuthorizable(TestIdentityProvider.ID_TEST_USER, User.class);
assertNotNull(u);
// user _should_ be re-synced
assertFalse(lastSynced == DefaultSyncContext.createSyncedIdentity(u).lastSynced());
} finally {
if (cs != null) {
cs.close();
}
}
}
Aggregations