Fix KeycloakQuarkusServerDeployableContainer to correctly configure map store

Closes #13721
This commit is contained in:
Michal Hajas 2022-08-10 15:39:19 +02:00 committed by Hynek Mlnařík
parent 1445646e77
commit ab431e3bd9
5 changed files with 42 additions and 15 deletions

View file

@ -54,7 +54,7 @@ import org.keycloak.testsuite.arquillian.SuiteContext;
public class KeycloakQuarkusServerDeployableContainer implements DeployableContainer<KeycloakQuarkusConfiguration> {
private static final int DEFAULT_SHUTDOWN_TIMEOUT_SECONDS = 10;
private static final String AUTH_SERVER_QUARKUS_MAP_STORAGE_PROFILE = "auth.server.quarkus.mapStorage.profile";
private static final String AUTH_SERVER_QUARKUS_MAP_STORAGE_PROFILE = "auth.server.quarkus.mapStorage.profile.config";
private static final Logger log = Logger.getLogger(KeycloakQuarkusServerDeployableContainer.class);
@ -247,6 +247,14 @@ public class KeycloakQuarkusServerDeployableContainer implements DeployableConta
String mapStorageProfile = System.getProperty(AUTH_SERVER_QUARKUS_MAP_STORAGE_PROFILE);
if (mapStorageProfile != null) {
// We need to drop optimized flag because --storage is build option therefore startup requires re-augmentation
commands.removeIf("--optimized"::equals);
// As config is re-augmented on startup we need to also add --http-relative-path as ant build from
// integration-arquillian/servers/auth-server/quarkus/ant/configure.xml is replaced by build invoked on
// startup when we add new build option below
commands.add("--http-relative-path=/auth");
switch (mapStorageProfile) {
case "chm":
commands.add("--storage=" + mapStorageProfile);
@ -256,6 +264,7 @@ public class KeycloakQuarkusServerDeployableContainer implements DeployableConta
commands.add("--db-username=" + System.getProperty("keycloak.map.storage.connectionsJpa.url"));
commands.add("--db-password=" + System.getProperty("keycloak.map.storage.connectionsJpa.user"));
commands.add("--db-url=" + System.getProperty("keycloak.map.storage.connectionsJpa.password"));
break;
case "hotrod":
commands.add("--storage=" + mapStorageProfile);
// TODO: URL / username / password

View file

@ -366,17 +366,21 @@ public class PermissionsTest extends AbstractKeycloakTest {
response.set(realm.partialImport(new PartialImportRepresentation()));
}
}, Resource.REALM, true);
invoke(new Invocation() {
public void invoke(RealmResource realm) {
realm.clearRealmCache();
}
}, Resource.REALM, true);
invoke(new Invocation() {
public void invoke(RealmResource realm) {
realm.clearUserCache();
}
}, Resource.REALM, true);
if (isJpaRealmProvider()) {
// Caching is disabled with the new store, we need to skip these invocations
invoke(new Invocation() {
public void invoke(RealmResource realm) {
realm.clearRealmCache();
}
}, Resource.REALM, true);
invoke(new Invocation() {
public void invoke(RealmResource realm) {
realm.clearUserCache();
}
}, Resource.REALM, true);
}
// Delete realm
invoke(new Invocation() {
public void invoke(RealmResource realm) {

View file

@ -64,9 +64,11 @@ public class ServerInfoTest extends AbstractKeycloakTest {
assertNotNull(info.getSystemInfo().getServerTime());
assertNotNull(info.getSystemInfo().getUptime());
Map<String, ProviderRepresentation> jpaProviders = info.getProviders().get("connectionsJpa").getProviders();
ProviderRepresentation jpaProvider = jpaProviders.values().iterator().next();
log.infof("JPA Connections provider info: %s", jpaProvider.getOperationalInfo());
if (isJpaRealmProvider()) {
Map<String, ProviderRepresentation> jpaProviders = info.getProviders().get("connectionsJpa").getProviders();
ProviderRepresentation jpaProvider = jpaProviders.values().iterator().next();
log.infof("JPA Connections provider info: %s", jpaProvider.getOperationalInfo());
}
}
@Override

View file

@ -17,10 +17,13 @@
package org.keycloak.testsuite.domainextension;
import org.junit.BeforeClass;
import org.junit.Test;
import org.keycloak.common.Profile;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.Assert;
import org.keycloak.testsuite.ProfileAssume;
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
import org.keycloak.testsuite.client.resources.TestExampleCompanyResource;
import org.keycloak.testsuite.util.RealmBuilder;
@ -47,6 +50,11 @@ public class CustomExtensionTest extends AbstractKeycloakTest {
testRealms.add(foo);
}
@BeforeClass
public static void checkNotMapStorage() {
ProfileAssume.assumeFeatureDisabled(Profile.Feature.MAP_STORAGE);
}
@Test
public void testDomainExtension() throws Exception {
companyResource().createCompany("foo", buildCompany("foo-company"));

View file

@ -190,7 +190,11 @@ public class DeployedScriptAuthenticatorTest extends AbstractFlowTest {
loginPage.login("user", "password");
events.expectLogin().user("user").detail(Details.USERNAME, "user").assertEvent();
events.expectLogin().user(okayUser()).detail(Details.USERNAME, "user").assertEvent();
}
private UserRepresentation okayUser() {
return adminClient.realm(TEST_REALM_NAME).users().search("user", true).get(0);
}
/**