KEYCLOAK-13770 - Working DefaultThemeManagerTest
This commit is contained in:
parent
da0c945475
commit
8cf35c9b7b
4 changed files with 24 additions and 6 deletions
|
@ -19,6 +19,8 @@
|
||||||
<offline.session.cache.owners>2</offline.session.cache.owners>
|
<offline.session.cache.owners>2</offline.session.cache.owners>
|
||||||
<login.failure.cache.owners>2</login.failure.cache.owners>
|
<login.failure.cache.owners>2</login.failure.cache.owners>
|
||||||
<auth.server.quarkus.cluster.config>local</auth.server.quarkus.cluster.config>
|
<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>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -111,6 +113,21 @@
|
||||||
<overwrite>true</overwrite>
|
<overwrite>true</overwrite>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</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>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|
|
@ -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.read-only-attributes=deniedFoo,deniedBar*,deniedSome/thing,deniedsome*thing
|
||||||
spi.user-profile.declarative-user-profile.admin-read-only-attributes=deniedSomeAdmin
|
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
|
# http client connection reuse settings
|
||||||
spi.connections-http-client.default.reuse-connections=false
|
spi.connections-http-client.default.reuse-connections=false
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
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.QUARKUS;
|
||||||
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;
|
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;
|
||||||
|
|
||||||
|
|
|
@ -6,19 +6,17 @@ import org.junit.Test;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
import org.keycloak.testsuite.AbstractKeycloakTest;
|
import org.keycloak.testsuite.AbstractKeycloakTest;
|
||||||
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
import org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude;
|
||||||
import org.keycloak.testsuite.util.ContainerAssume;
|
|
||||||
import org.keycloak.theme.Theme;
|
import org.keycloak.theme.Theme;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.QUARKUS;
|
|
||||||
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;
|
import static org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude.AuthServer.REMOTE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:vincent.letarouilly@gmail.com">Vincent Letarouilly</a>
|
* @author <a href="mailto:vincent.letarouilly@gmail.com">Vincent Letarouilly</a>
|
||||||
*/
|
*/
|
||||||
@AuthServerContainerExclude({REMOTE, QUARKUS})
|
@AuthServerContainerExclude({REMOTE})
|
||||||
public class DefaultThemeManagerTest extends AbstractKeycloakTest {
|
public class DefaultThemeManagerTest extends AbstractKeycloakTest {
|
||||||
|
|
||||||
private static final String THEME_NAME = "environment-agnostic";
|
private static final String THEME_NAME = "environment-agnostic";
|
||||||
|
@ -38,11 +36,10 @@ public class DefaultThemeManagerTest extends AbstractKeycloakTest {
|
||||||
// KEYCLOAK-6698
|
// KEYCLOAK-6698
|
||||||
@Test
|
@Test
|
||||||
public void systemPropertiesSubstitutionInThemeProperties() {
|
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 -> {
|
testingClient.server().run(session -> {
|
||||||
try {
|
try {
|
||||||
Theme theme = session.theme().getTheme(THEME_NAME, Theme.Type.LOGIN);
|
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("Keycloak is awesome", theme.getProperties().getProperty("system.property.found"));
|
||||||
Assert.assertEquals("${missing_system_property}", theme.getProperties().getProperty("system.property.missing"));
|
Assert.assertEquals("${missing_system_property}", theme.getProperties().getProperty("system.property.missing"));
|
||||||
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("system.property.missing.with.default"));
|
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("system.property.missing.with.default"));
|
||||||
|
@ -58,6 +55,7 @@ public class DefaultThemeManagerTest extends AbstractKeycloakTest {
|
||||||
testingClient.server().run(session -> {
|
testingClient.server().run(session -> {
|
||||||
try {
|
try {
|
||||||
Theme theme = session.theme().getTheme(THEME_NAME, Theme.Type.LOGIN);
|
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("${env.MISSING_ENVIRONMENT_VARIABLE}", theme.getProperties().getProperty("env.missing"));
|
||||||
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("env.missingWithDefault"));
|
Assert.assertEquals("defaultValue", theme.getProperties().getProperty("env.missingWithDefault"));
|
||||||
if (System.getenv().containsKey("HOMEPATH")) {
|
if (System.getenv().containsKey("HOMEPATH")) {
|
||||||
|
|
Loading…
Reference in a new issue