KEYCLOAK-13770 - Working DefaultThemeManagerTest

This commit is contained in:
Dominik 2021-09-30 08:45:45 +02:00 committed by Pedro Igor
parent da0c945475
commit 8cf35c9b7b
4 changed files with 24 additions and 6 deletions

View file

@ -19,6 +19,8 @@
<offline.session.cache.owners>2</offline.session.cache.owners>
<login.failure.cache.owners>2</login.failure.cache.owners>
<auth.server.quarkus.cluster.config>local</auth.server.quarkus.cluster.config>
<!-- Path to testsuite/test resources : Themes-->
<keycloak.base.test.resource>${project.parent.basedir}/../../tests/base/src/test/resources</keycloak.base.test.resource>
</properties>
<dependencies>
@ -111,6 +113,21 @@
<overwrite>true</overwrite>
</configuration>
</execution>
<execution>
<id>add-extending-theme</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${auth.server.home}/themes</outputDirectory>
<resources>
<resource>
<directory>${keycloak.base.test.resource}/theme</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>

View file

@ -27,5 +27,8 @@ spi.truststore.file.password=secret
spi.user-profile.declarative-user-profile.read-only-attributes=deniedFoo,deniedBar*,deniedSome/thing,deniedsome*thing
spi.user-profile.declarative-user-profile.admin-read-only-attributes=deniedSomeAdmin
#theme folders dir
spi.theme.folder.dir=${kc.home.dir:}/themes
# http client connection reuse settings
spi.connections-http-client.default.reuse-connections=false

View file

@ -36,7 +36,7 @@ import java.util.List;
import java.util.stream.Collectors;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.QUARKUS;
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;

View file

@ -6,19 +6,17 @@ import org.junit.Test;
import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.testsuite.AbstractKeycloakTest;
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
import org.keycloak.testsuite.util.ContainerAssume;
import org.keycloak.theme.Theme;
import java.io.IOException;
import java.util.List;
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.QUARKUS;
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;
/**
* @author <a href="mailto:vincent.letarouilly@gmail.com">Vincent Letarouilly</a>
*/
@AuthServerContainerExclude({REMOTE, QUARKUS})
@AuthServerContainerExclude({REMOTE})
public class DefaultThemeManagerTest extends AbstractKeycloakTest {
private static final String THEME_NAME = "environment-agnostic";
@ -38,11 +36,10 @@ public class DefaultThemeManagerTest extends AbstractKeycloakTest {
// KEYCLOAK-6698
@Test
public void systemPropertiesSubstitutionInThemeProperties() {
// TODO fix this test on auth-server-wildfly. There is an issue with setup of System properties (other JVM).
ContainerAssume.assumeAuthServerUndertow();
testingClient.server().run(session -> {
try {
Theme theme = session.theme().getTheme(THEME_NAME, Theme.Type.LOGIN);
Assert.assertEquals("getTheme(...) returns default theme when no matching theme found, but we need " + THEME_NAME + " theme deployed.",THEME_NAME, theme.getName());
Assert.assertEquals("Keycloak is awesome", theme.getProperties().getProperty("system.property.found"));
Assert.assertEquals("${missing_system_property}", theme.getProperties().getProperty("system.property.missing"));
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("system.property.missing.with.default"));
@ -58,6 +55,7 @@ public class DefaultThemeManagerTest extends AbstractKeycloakTest {
testingClient.server().run(session -> {
try {
Theme theme = session.theme().getTheme(THEME_NAME, Theme.Type.LOGIN);
Assert.assertEquals("getTheme(...) returns default theme when no matching theme found, but we need " + THEME_NAME + " theme deployed.",THEME_NAME, theme.getName());
Assert.assertEquals("${env.MISSING_ENVIRONMENT_VARIABLE}", theme.getProperties().getProperty("env.missing"));
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("env.missingWithDefault"));
if (System.getenv().containsKey("HOMEPATH")) {