Skip to content

Commit

Permalink
KEYCLOAK-13770 - Working DefaultThemeManagerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
DGuhr authored and pedroigor committed Oct 1, 2021
1 parent da0c945 commit 8cf35c9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@
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:[email protected]">Vincent Letarouilly</a>
*/
@AuthServerContainerExclude({REMOTE, QUARKUS})
@AuthServerContainerExclude({REMOTE})
public class DefaultThemeManagerTest extends AbstractKeycloakTest {

private static final String THEME_NAME = "environment-agnostic";
Expand All @@ -38,11 +36,10 @@ public void addTestRealms(List<RealmRepresentation> testRealms) {
// 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"));
Expand All @@ -58,6 +55,7 @@ public void environmentVariablesSubstitutionInThemeProperties() {
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")) {
Expand Down

0 comments on commit 8cf35c9

Please sign in to comment.