Search in sources :

Example 26 with UserManager

use of org.keycloak.models.UserManager in project keycloak by keycloak.

the class UserConsentWithUserStorageModelTest method after.

@After
public void after() {
    testingClient.server().run(session -> {
        RealmManager realmManager = new RealmManager(session);
        RealmModel realm = realmManager.getRealmByName("original");
        if (realm != null) {
            session.sessions().removeUserSessions(realm);
            UserModel user = session.users().getUserByUsername(realm, "user");
            UserModel user1 = session.users().getUserByUsername(realm, "user1");
            UserModel user2 = session.users().getUserByUsername(realm, "user2");
            UserModel user3 = session.users().getUserByUsername(realm, "user3");
            UserManager um = new UserManager(session);
            if (user != null) {
                um.removeUser(realm, user);
            }
            if (user1 != null) {
                um.removeUser(realm, user1);
            }
            if (user2 != null) {
                um.removeUser(realm, user2);
            }
            if (user3 != null) {
                um.removeUser(realm, user3);
            }
            realmManager.removeRealm(realm);
        }
    });
}
Also used : RealmModel(org.keycloak.models.RealmModel) UserModel(org.keycloak.models.UserModel) UserManager(org.keycloak.models.UserManager) RealmManager(org.keycloak.services.managers.RealmManager) After(org.junit.After)

Aggregations

UserManager (org.keycloak.models.UserManager)26 UserModel (org.keycloak.models.UserModel)25 RealmModel (org.keycloak.models.RealmModel)20 After (org.junit.After)7 KeycloakSession (org.keycloak.models.KeycloakSession)7 Test (org.junit.Test)6 RealmManager (org.keycloak.services.managers.RealmManager)5 AbstractTestRealmKeycloakTest (org.keycloak.testsuite.AbstractTestRealmKeycloakTest)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)4 ModelTest (org.keycloak.testsuite.arquillian.annotation.ModelTest)4 UserSessionModel (org.keycloak.models.UserSessionModel)3 ClientModel (org.keycloak.models.ClientModel)2 CachedUserModel (org.keycloak.models.cache.CachedUserModel)2 UserCache (org.keycloak.models.cache.UserCache)2 ClientManager (org.keycloak.services.managers.ClientManager)2 DELETE (javax.ws.rs.DELETE)1 NoCache (org.jboss.resteasy.annotations.cache.NoCache)1 EventBuilder (org.keycloak.events.EventBuilder)1 KeycloakContext (org.keycloak.models.KeycloakContext)1 ModelException (org.keycloak.models.ModelException)1