diff --git a/testsuite/integration-arquillian/tests/base/pom.xml b/testsuite/integration-arquillian/tests/base/pom.xml
index 5a24cd3a4d..70bf0df018 100644
--- a/testsuite/integration-arquillian/tests/base/pom.xml
+++ b/testsuite/integration-arquillian/tests/base/pom.xml
@@ -52,6 +52,11 @@
+
+ commons-configuration
+ commons-configuration
+ 1.10
+
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/Login.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/Login.java
index 875306f345..dcee089960 100644
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/Login.java
+++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/Login.java
@@ -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();
}
}
diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/model/Theme.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/model/Theme.java
deleted file mode 100644
index a063d6ce2f..0000000000
--- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/model/Theme.java
+++ /dev/null
@@ -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;
- }
-
-
-}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java
index bbab45015e..5c3a906798 100644
--- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java
+++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/AbstractKeycloakTest.java
@@ -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",
@@ -221,7 +225,7 @@ public abstract class AbstractKeycloakTest {
realmRepresentation.setEnabled(true);
realmRepresentation.setRegistrationAllowed(true);
adminClient.realms().create(realmRepresentation);
-
+
// List requiredActions = adminClient.realm(realm).flows().getRequiredActions();
// for (RequiredActionProviderRepresentation a : requiredActions) {
// a.setEnabled(false);
@@ -230,28 +234,28 @@ public abstract class AbstractKeycloakTest {
// }
}
}
-
+
public String createUser(String realm, String username, String password, String ... requiredActions) {
List requiredUserActions = Arrays.asList(requiredActions);
-
+
UserRepresentation homer = new UserRepresentation();
homer.setEnabled(true);
homer.setUsername(username);
homer.setRequiredActions(requiredUserActions);
-
+
return ApiUtil.createUserAndResetPasswordWithAdminClient(adminClient.realm(realm), homer, password);
}
-
+
public void setRequiredActionEnabled(String realm, String requiredAction, boolean enabled, boolean defaultAction) {
AuthenticationManagementResource managementResource = adminClient.realm(realm).flows();
-
+
RequiredActionProviderRepresentation action = managementResource.getRequiredAction(requiredAction);
action.setEnabled(enabled);
action.setDefaultAction(defaultAction);
-
+
managementResource.updateRequiredAction(requiredAction, action);
}
-
+
public void setRequiredActionEnabled(String realm, String userId, String requiredAction, boolean enabled) {
UsersResource usersResource = adminClient.realm(realm).users();
@@ -264,8 +268,20 @@ public abstract class AbstractKeycloakTest {
} else if (!enabled && requiredActions.contains(requiredAction)) {
requiredActions.remove(requiredAction);
}
-
+
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;
+ }
+
}
diff --git a/testsuite/integration-arquillian/tests/base/src/test/resources/test-constants.properties b/testsuite/integration-arquillian/tests/base/src/test/resources/test-constants.properties
new file mode 100644
index 0000000000..2e405b8455
--- /dev/null
+++ b/testsuite/integration-arquillian/tests/base/src/test/resources/test-constants.properties
@@ -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
\ No newline at end of file
diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java
index 3503880f23..2d927a942d 100644
--- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java
+++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/federation/LdapUserProviderForm.java
@@ -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 getVendors() {
+ waitUntilElement(By.id("vendor")).is().present();
+
+ List vendorsElements = vendorSelect.getOptions();
+ List 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);
diff --git a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/realm/GeneralSettings.java b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/realm/GeneralSettings.java
index a2a32de2a6..32387a59a8 100644
--- a/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/realm/GeneralSettings.java
+++ b/testsuite/integration-arquillian/tests/other/console/src/main/java/org/keycloak/testsuite/console/page/realm/GeneralSettings.java
@@ -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);
}
}
diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/federation/LdapUserFederationTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/federation/LdapUserFederationTest.java
index a4eb39981b..d0d2a2731a 100644
--- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/federation/LdapUserFederationTest.java
+++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/federation/LdapUserFederationTest.java
@@ -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 vendorsExpected = (List) (List>) getConstantsProperties().getList("ldap-vendors");
+ List 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) {
diff --git a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/realm/ThemeSettingsTest.java b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/realm/ThemeSettingsTest.java
index 092b89324d..57ada69c5d 100644
--- a/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/realm/ThemeSettingsTest.java
+++ b/testsuite/integration-arquillian/tests/other/console/src/test/java/org/keycloak/testsuite/console/realm/ThemeSettingsTest.java
@@ -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();