use of org.keycloak.models.sessions.infinispan.InfinispanUserSessionProvider in project keycloak by keycloak.
the class OfflineSessionPersistenceTest method testOfflineSessionLoadingAfterCacheRemoval.
@Test
@RequireProvider(UserSessionPersisterProvider.class)
@RequireProvider(value = UserSessionProvider.class, only = InfinispanUserSessionProviderFactory.PROVIDER_ID)
public void testOfflineSessionLoadingAfterCacheRemoval() {
List<String> offlineSessionIds = createOfflineSessions(realmId, userIds);
assertOfflineSessionsExist(realmId, offlineSessionIds);
// Simulate server restart
reinitializeKeycloakSessionFactory();
assertOfflineSessionsExist(realmId, offlineSessionIds);
// remove sessions from the cache
withRealm(realmId, (session, realm) -> {
// Delete local user cache (persisted sessions are still kept)
UserSessionProvider provider = session.getProvider(UserSessionProvider.class);
// Remove in-memory representation of the offline sessions
((InfinispanUserSessionProvider) provider).removeLocalUserSessions(realm.getId(), true);
return null;
});
// assert sessions are lazily loaded from DB
assertOfflineSessionsExist(realmId, offlineSessionIds);
}
Aggregations