Merge pull request #2378 from vmuzikar/master
Add properties file for some "constants" used in integration tests
This commit is contained in:
commit
50ed089980
9 changed files with 100 additions and 66 deletions
|
@ -52,6 +52,11 @@
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-configuration</groupId>
|
||||||
|
<artifactId>commons-configuration</artifactId>
|
||||||
|
<version>1.10</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -18,6 +18,7 @@ package org.keycloak.testsuite.auth.page.login;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.keycloak.testsuite.auth.page.AuthRealm;
|
import org.keycloak.testsuite.auth.page.AuthRealm;
|
||||||
|
import org.openqa.selenium.By;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
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 OIDC = "openid-connect";
|
||||||
public static final String SAML = "saml";
|
public static final String SAML = "saml";
|
||||||
public static final String LOGIN_ACTION = "login-action";
|
public static final String LOGIN_ACTION = "login-action";
|
||||||
|
private String keycloakThemeCssName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UriBuilder createUriBuilder() {
|
public UriBuilder createUriBuilder() {
|
||||||
|
@ -58,15 +60,23 @@ public abstract class Login extends AuthRealm {
|
||||||
return form;
|
return form;
|
||||||
}
|
}
|
||||||
|
|
||||||
@FindBy(css = "link[href*='login/keycloak/css/login.css']")
|
public void setKeycloakThemeCssName(String name) {
|
||||||
private WebElement keycloakTheme;
|
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() {
|
public void waitForKeycloakThemeNotPresent() {
|
||||||
waitUntilElement(keycloakTheme).is().not().present();
|
waitUntilElement(getKeycloakThemeLocator()).is().not().present();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForKeycloakThemePresent() {
|
public void waitForKeycloakThemePresent() {
|
||||||
waitUntilElement(keycloakTheme).is().present();
|
waitUntilElement(getKeycloakThemeLocator()).is().present();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -16,6 +16,8 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite;
|
package org.keycloak.testsuite;
|
||||||
|
|
||||||
|
import org.apache.commons.configuration.ConfigurationException;
|
||||||
|
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||||
import org.keycloak.testsuite.arquillian.TestContext;
|
import org.keycloak.testsuite.arquillian.TestContext;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -103,6 +105,8 @@ public abstract class AbstractKeycloakTest {
|
||||||
|
|
||||||
protected UserRepresentation adminUser;
|
protected UserRepresentation adminUser;
|
||||||
|
|
||||||
|
private PropertiesConfiguration constantsProperties;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void beforeAbstractKeycloakTest() {
|
public void beforeAbstractKeycloakTest() {
|
||||||
adminClient = Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth",
|
adminClient = Keycloak.getInstance(AuthServerTestEnricher.getAuthServerContextRoot() + "/auth",
|
||||||
|
@ -268,4 +272,16 @@ public abstract class AbstractKeycloakTest {
|
||||||
userResource.update(userRepresentation);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
@ -11,6 +11,9 @@ import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.Select;
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fkiss, pdrozd
|
* @author fkiss, pdrozd
|
||||||
*/
|
*/
|
||||||
|
@ -188,6 +191,21 @@ public class LdapUserProviderForm extends Form {
|
||||||
vendorSelect.selectByVisibleText(vendor);
|
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) {
|
public void selectAuthenticationType(String authenticationType) {
|
||||||
waitUntilElement(By.id("authType")).is().present();
|
waitUntilElement(By.id("authType")).is().present();
|
||||||
authTypeSelect.selectByVisibleText(authenticationType);
|
authTypeSelect.selectByVisibleText(authenticationType);
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
|
|
||||||
package org.keycloak.testsuite.console.page.realm;
|
package org.keycloak.testsuite.console.page.realm;
|
||||||
|
|
||||||
import org.keycloak.testsuite.model.Theme;
|
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
import org.openqa.selenium.support.ui.Select;
|
import org.openqa.selenium.support.ui.Select;
|
||||||
|
@ -58,19 +57,19 @@ public class GeneralSettings extends RealmSettings {
|
||||||
saveButton.click();
|
saveButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectLoginTheme(Theme theme) {
|
public void selectLoginTheme(String theme) {
|
||||||
loginThemeSelect.selectByVisibleText(theme.getName());
|
loginThemeSelect.selectByVisibleText(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selecAccountTheme(Theme theme) {
|
public void selecAccountTheme(String theme) {
|
||||||
accountThemeSelect.selectByVisibleText(theme.getName());
|
accountThemeSelect.selectByVisibleText(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectAdminTheme(Theme theme) {
|
public void selectAdminTheme(String theme) {
|
||||||
adminThemeSelect.selectByVisibleText(theme.getName());
|
adminThemeSelect.selectByVisibleText(theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectEmailTheme(Theme theme) {
|
public void selectEmailTheme(String theme) {
|
||||||
emailThemeSelect.selectByVisibleText(theme.getName());
|
emailThemeSelect.selectByVisibleText(theme);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package org.keycloak.testsuite.console.federation;
|
package org.keycloak.testsuite.console.federation;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.configuration.ConfigurationException;
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
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.AbstractConsoleTest;
|
||||||
import org.keycloak.testsuite.console.page.federation.CreateLdapUserProvider;
|
import org.keycloak.testsuite.console.page.federation.CreateLdapUserProvider;
|
||||||
import org.keycloak.util.ldap.LDAPEmbeddedServer;
|
import org.keycloak.util.ldap.LDAPEmbeddedServer;
|
||||||
|
import org.openqa.selenium.WebElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fkiss, pdrozd
|
* @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,
|
private void assertLdapProviderSetting(UserFederationProviderRepresentation ufpr, String name, int priority,
|
||||||
String editMode, String syncRegistrations, String vendor, String searchScope, String connectionPooling,
|
String editMode, String syncRegistrations, String vendor, String searchScope, String connectionPooling,
|
||||||
String pagination, String enableAccountAfterPasswordUpdate) {
|
String pagination, String enableAccountAfterPasswordUpdate) {
|
||||||
|
|
|
@ -17,10 +17,10 @@
|
||||||
*/
|
*/
|
||||||
package org.keycloak.testsuite.console.realm;
|
package org.keycloak.testsuite.console.realm;
|
||||||
|
|
||||||
|
import org.apache.commons.configuration.ConfigurationException;
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.testsuite.model.Theme;
|
|
||||||
import org.keycloak.testsuite.console.page.realm.ThemeSettings;
|
import org.keycloak.testsuite.console.page.realm.ThemeSettings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,8 +41,10 @@ public class ThemeSettingsTest extends AbstractRealmTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void changeLoginThemeTest() {
|
public void changeLoginThemeTest() throws ConfigurationException {
|
||||||
themeSettingsPage.changeLoginTheme(Theme.BASE.getName());
|
testRealmLoginPage.setKeycloakThemeCssName(getConstantsProperties().getString("theme-default-css-name"));
|
||||||
|
|
||||||
|
themeSettingsPage.changeLoginTheme("base");
|
||||||
themeSettingsPage.saveTheme();
|
themeSettingsPage.saveTheme();
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -51,7 +53,7 @@ public class ThemeSettingsTest extends AbstractRealmTest {
|
||||||
testRealmAdminConsolePage.logOut();
|
testRealmAdminConsolePage.logOut();
|
||||||
|
|
||||||
themeSettingsPage.navigateTo();
|
themeSettingsPage.navigateTo();
|
||||||
themeSettingsPage.changeLoginTheme(Theme.KEYCLOAK.getName());
|
themeSettingsPage.changeLoginTheme(getConstantsProperties().getString("theme-default-name"));
|
||||||
themeSettingsPage.saveTheme();
|
themeSettingsPage.saveTheme();
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
|
Loading…
Reference in a new issue