Merge pull request #2378 from vmuzikar/master

Add properties file for some "constants" used in integration tests
This commit is contained in:
Stian Thorgersen 2016-03-21 10:37:29 +01:00
commit 50ed089980
9 changed files with 100 additions and 66 deletions

View file

@ -52,6 +52,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
</dependencies>
<build>

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

@ -16,6 +16,8 @@
*/
package org.keycloak.testsuite;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.keycloak.testsuite.arquillian.TestContext;
import java.util.ArrayList;
import java.util.Arrays;
@ -103,6 +105,8 @@ public abstract class AbstractKeycloakTest {
protected UserRepresentation adminUser;
private PropertiesConfiguration constantsProperties;
@Before
public void beforeAbstractKeycloakTest() {
adminClient = Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth",
@ -268,4 +272,16 @@ public abstract class AbstractKeycloakTest {
userResource.update(userRepresentation);
}
private void loadConstantsProperties() throws ConfigurationException {
constantsProperties = new PropertiesConfiguration("test-constants.properties");
constantsProperties.setThrowExceptionOnMissing(true);
}
protected PropertiesConfiguration getConstantsProperties() throws ConfigurationException {
if (constantsProperties == null) {
loadConstantsProperties();
}
return constantsProperties;
}
}

View file

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

View file

@ -11,6 +11,9 @@ import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.Select;
import java.util.ArrayList;
import java.util.List;
/**
* @author fkiss, pdrozd
*/
@ -188,6 +191,21 @@ public class LdapUserProviderForm extends Form {
vendorSelect.selectByVisibleText(vendor);
}
public List<String> getVendors() {
waitUntilElement(By.id("vendor")).is().present();
List<WebElement> vendorsElements = vendorSelect.getOptions();
List<String> vendorsString = new ArrayList<>();
for (WebElement vendorElement : vendorsElements) {
String text = vendorElement.getText();
if (text.equals("")) {continue;}
vendorsString.add(text);
}
return vendorsString;
}
public void selectAuthenticationType(String authenticationType) {
waitUntilElement(By.id("authType")).is().present();
authTypeSelect.selectByVisibleText(authenticationType);

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

@ -1,9 +1,12 @@
package org.keycloak.testsuite.console.federation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.Properties;
import org.apache.commons.configuration.ConfigurationException;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Ignore;
import org.junit.Test;
@ -12,6 +15,7 @@ import org.keycloak.representations.idm.UserFederationProviderRepresentation;
import org.keycloak.testsuite.console.AbstractConsoleTest;
import org.keycloak.testsuite.console.page.federation.CreateLdapUserProvider;
import org.keycloak.util.ldap.LDAPEmbeddedServer;
import org.openqa.selenium.WebElement;
/**
* @author fkiss, pdrozd
@ -158,6 +162,21 @@ public class LdapUserFederationTest extends AbstractConsoleTest {
}
}
@Test
public void checkVendors() throws ConfigurationException {
createLdapUserProvider.navigateTo();
List<String> vendorsExpected = (List<String>) (List<?>) getConstantsProperties().getList("ldap-vendors");
List<String> vendorsActual = createLdapUserProvider.form().getVendors();
int vendorsExpectedSize = vendorsExpected.size();
int vendorsActualSize = vendorsActual.size();
assertTrue("Expected vendors count: " + vendorsExpectedSize + "; actual count: " + vendorsActualSize,
vendorsExpectedSize == vendorsActualSize);
assertTrue("Vendors list doesn't match", vendorsExpected.containsAll(vendorsActual));
}
private void assertLdapProviderSetting(UserFederationProviderRepresentation ufpr, String name, int priority,
String editMode, String syncRegistrations, String vendor, String searchScope, String connectionPooling,
String pagination, String enableAccountAfterPasswordUpdate) {

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();