From e2bd99e9e40b5de9b03db4edebcba956ae8ca4aa Mon Sep 17 00:00:00 2001 From: vramik Date: Wed, 26 Feb 2020 10:07:37 +0100 Subject: [PATCH] KEYCLOAK-13097 fix UserStorageTest - add cleanup after test --- .../keycloak/testsuite/federation/UserMapStorage.java | 4 ++-- .../testsuite/federation/UserMapStorageFactory.java | 9 +++++++-- .../testsuite/federation/storage/UserStorageTest.java | 8 +++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java index a6d80c3474..4c1572ad99 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorage.java @@ -60,8 +60,8 @@ public class UserMapStorage implements UserLookupProvider, UserStorageProvider, private static final Logger log = Logger.getLogger(UserMapStorage.class); - protected Map userPasswords; - protected ConcurrentMap> userGroups; + protected final Map userPasswords; + protected final ConcurrentMap> userGroups; protected ComponentModel model; protected KeycloakSession session; protected EditMode editMode; diff --git a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorageFactory.java b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorageFactory.java index f7f36be22c..6c9006ca3c 100644 --- a/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorageFactory.java +++ b/testsuite/integration-arquillian/servers/auth-server/services/testsuite-providers/src/main/java/org/keycloak/testsuite/federation/UserMapStorageFactory.java @@ -48,8 +48,8 @@ public class UserMapStorageFactory implements UserStorageProviderFactory userPasswords = new ConcurrentHashMap<>(); - protected ConcurrentMap> userGroups = new ConcurrentHashMap<>(); + private final Map userPasswords = new ConcurrentHashMap<>(); + private final ConcurrentMap> userGroups = new ConcurrentHashMap<>(); @Override public List getConfigProperties() { @@ -80,4 +80,9 @@ public class UserMapStorageFactory implements UserStorageProviderFactory { RealmModel realm = session.realms().getRealmByName("test"); if (realm == null) { @@ -154,6 +155,11 @@ public class UserStorageTest extends AbstractAuthTest { 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(); }); }