Add support for testing default theme name in prop file

This commit is contained in:
Vaclav Muzikar 2016-02-26 13:59:28 +01:00
parent ddc0792733
commit 2d7424c697
5 changed files with 31 additions and 57 deletions

View file

@ -18,6 +18,7 @@ package org.keycloak.testsuite.auth.page.login;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.auth.page.AuthRealm;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
@ -36,6 +37,7 @@ public abstract class Login extends AuthRealm {
public static final String OIDC = "openid-connect";
public static final String SAML = "saml";
public static final String LOGIN_ACTION = "login-action";
private String keycloakThemeCssName;
@Override
public UriBuilder createUriBuilder() {
@ -58,15 +60,23 @@ public abstract class Login extends AuthRealm {
return form;
}
@FindBy(css = "link[href*='login/keycloak/css/login.css']")
private WebElement keycloakTheme;
public void setKeycloakThemeCssName(String name) {
keycloakThemeCssName = name;
}
protected By getKeycloakThemeLocator() {
if (keycloakThemeCssName == null) {
throw new IllegalStateException("keycloakThemeCssName property must be set");
}
return By.cssSelector("link[href*='login/" + keycloakThemeCssName + "/css/login.css']");
}
public void waitForKeycloakThemeNotPresent() {
waitUntilElement(keycloakTheme).is().not().present();
waitUntilElement(getKeycloakThemeLocator()).is().not().present();
}
public void waitForKeycloakThemePresent() {
waitUntilElement(keycloakTheme).is().present();
waitUntilElement(getKeycloakThemeLocator()).is().present();
}
}

View file

@ -1,39 +0,0 @@
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.keycloak.testsuite.model;
/**
*
* @author Petr Mensik
*/
public enum Theme {
BASE("base"), KEYCLOAK("keycloak"), PATTERNFLY("patternfly");
private final String name;
private Theme(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

View file

@ -1,2 +1,4 @@
# Some constants used in tests which may vary
ldap-vendors = Active Directory,Red Hat Directory Server,Tivoli,Novell eDirectory,Other
ldap-vendors = Active Directory,Red Hat Directory Server,Tivoli,Novell eDirectory,Other
theme-default-name = keycloak
theme-default-css-name = keycloak

View file

@ -18,7 +18,6 @@
package org.keycloak.testsuite.console.page.realm;
import org.keycloak.testsuite.model.Theme;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
@ -58,19 +57,19 @@ public class GeneralSettings extends RealmSettings {
saveButton.click();
}
public void selectLoginTheme(Theme theme) {
loginThemeSelect.selectByVisibleText(theme.getName());
public void selectLoginTheme(String theme) {
loginThemeSelect.selectByVisibleText(theme);
}
public void selecAccountTheme(Theme theme) {
accountThemeSelect.selectByVisibleText(theme.getName());
public void selecAccountTheme(String theme) {
accountThemeSelect.selectByVisibleText(theme);
}
public void selectAdminTheme(Theme theme) {
adminThemeSelect.selectByVisibleText(theme.getName());
public void selectAdminTheme(String theme) {
adminThemeSelect.selectByVisibleText(theme);
}
public void selectEmailTheme(Theme theme) {
emailThemeSelect.selectByVisibleText(theme.getName());
public void selectEmailTheme(String theme) {
emailThemeSelect.selectByVisibleText(theme);
}
}

View file

@ -17,10 +17,10 @@
*/
package org.keycloak.testsuite.console.realm;
import org.apache.commons.configuration.ConfigurationException;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Before;
import org.junit.Test;
import org.keycloak.testsuite.model.Theme;
import org.keycloak.testsuite.console.page.realm.ThemeSettings;
/**
@ -41,8 +41,10 @@ public class ThemeSettingsTest extends AbstractRealmTest {
}
@Test
public void changeLoginThemeTest() {
themeSettingsPage.changeLoginTheme(Theme.BASE.getName());
public void changeLoginThemeTest() throws ConfigurationException {
testRealmLoginPage.setKeycloakThemeCssName(getConstantsProperties().getString("theme-default-css-name"));
themeSettingsPage.changeLoginTheme("base");
themeSettingsPage.saveTheme();
testRealmAdminConsolePage.navigateTo();
@ -51,7 +53,7 @@ public class ThemeSettingsTest extends AbstractRealmTest {
testRealmAdminConsolePage.logOut();
themeSettingsPage.navigateTo();
themeSettingsPage.changeLoginTheme(Theme.KEYCLOAK.getName());
themeSettingsPage.changeLoginTheme(getConstantsProperties().getString("theme-default-name"));
themeSettingsPage.saveTheme();
testRealmAdminConsolePage.navigateTo();