use of org.keycloak.testsuite.arquillian.annotation.ModelTest in project keycloak by keycloak.
the class UserConsentWithUserStorageModelTest method deleteClientStorageTest.
@Test
@ModelTest
public void deleteClientStorageTest(KeycloakSession session) {
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sesDelClientStore1) -> {
KeycloakSession currentSession = sesDelClientStore1;
RealmModel realm = currentSession.realms().getRealmByName("original");
realm.removeComponent(clientStorageComponent);
});
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sesDelClientStore2) -> {
KeycloakSession currentSession = sesDelClientStore2;
RealmModel realm = currentSession.realms().getRealmByName("original");
ClientModel hardcodedClient = currentSession.clients().getClientByClientId(realm, "hardcoded-client");
Assert.assertNull(hardcodedClient);
UserModel mary = currentSession.users().getUserByUsername(realm, "mary");
Assert.assertEquals(1, currentSession.users().getConsentsStream(realm, mary.getId()).count());
});
}
use of org.keycloak.testsuite.arquillian.annotation.ModelTest in project keycloak by keycloak.
the class UserConsentWithUserStorageModelTest method deleteUserTest.
@Test
@ModelTest
public void deleteUserTest(KeycloakSession session) {
KeycloakModelUtils.runJobInTransaction(session.getKeycloakSessionFactory(), (KeycloakSession sessionDelete) -> {
// Validate user deleted without any referential constraint errors
KeycloakSession currentSession = sessionDelete;
RealmModel realm = currentSession.realms().getRealmByName("original");
UserModel john = currentSession.users().getUserByUsername(realm, "john");
currentSession.users().removeUser(realm, john);
UserModel mary = currentSession.users().getUserByUsername(realm, "mary");
currentSession.users().removeUser(realm, mary);
});
}
Aggregations