Search in sources :

Example 1 with UserMapStorageFactory

use of org.keycloak.testsuite.federation.UserMapStorageFactory in project keycloak by keycloak.

the class UserStorageTest method afterTestCleanUp.

@After
public void afterTestCleanUp() throws URISyntaxException, IOException {
    testingClient.server().run(session -> {
        RealmModel realm = session.realms().getRealmByName("test");
        if (realm == null) {
            return;
        }
        UserModel user = session.users().getUserByUsername(realm, "thor");
        if (user != null) {
            session.userLocalStorage().removeUser(realm, user);
            session.userCache().clear();
        }
        // we need to clear userPasswords and userGroups from UserMapStorageFactory
        UserMapStorageFactory userMapStorageFactory = (UserMapStorageFactory) session.getKeycloakSessionFactory().getProviderFactory(UserStorageProvider.class, UserMapStorageFactory.PROVIDER_ID);
        Assert.assertNotNull(userMapStorageFactory);
        userMapStorageFactory.clear();
    });
}
Also used : RealmModel(org.keycloak.models.RealmModel) CachedUserModel(org.keycloak.models.cache.CachedUserModel) UserModel(org.keycloak.models.UserModel) UserMapStorageFactory(org.keycloak.testsuite.federation.UserMapStorageFactory) UserStorageProvider(org.keycloak.storage.UserStorageProvider) After(org.junit.After)

Aggregations

After (org.junit.After)1 RealmModel (org.keycloak.models.RealmModel)1 UserModel (org.keycloak.models.UserModel)1 CachedUserModel (org.keycloak.models.cache.CachedUserModel)1 UserStorageProvider (org.keycloak.storage.UserStorageProvider)1 UserMapStorageFactory (org.keycloak.testsuite.federation.UserMapStorageFactory)1