From 340afb2a50867778752d2340157c5a9229bdc830 Mon Sep 17 00:00:00 2001 From: vmuzikar Date: Thu, 1 Feb 2018 12:42:05 +0100 Subject: [PATCH] KEYCLOAK-6450 Stabilize WelcomePageTest --- .../integration-arquillian/HOW-TO-RUN.md | 9 +-- .../testsuite/auth/page/WelcomePage.java | 18 +++-- .../tests/other/pom.xml | 6 ++ .../tests/other/welcome-page/pom.xml | 71 +++++++++++++++++++ .../welcomepage/WelcomePageTest.java | 18 ++--- 5 files changed, 92 insertions(+), 30 deletions(-) create mode 100644 testsuite/integration-arquillian/tests/other/welcome-page/pom.xml rename testsuite/integration-arquillian/tests/{base => other/welcome-page}/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java (89%) diff --git a/testsuite/integration-arquillian/HOW-TO-RUN.md b/testsuite/integration-arquillian/HOW-TO-RUN.md index f804bf1555..b30e836131 100644 --- a/testsuite/integration-arquillian/HOW-TO-RUN.md +++ b/testsuite/integration-arquillian/HOW-TO-RUN.md @@ -273,20 +273,17 @@ mvn -f testsuite/integration-arquillian/tests/other/console/pom.xml \ ``` ## Welcome Page tests -The Welcome Page tests need to be run on WildFly/EAP and with `-Dskip.add.user.json` switch. So that they are disabled by default and are meant to be run separately. +The Welcome Page tests need to be run on WildFly/EAP. So that they are disabled by default and are meant to be run separately. # Prepare servers mvn -f testsuite/integration-arquillian/servers/pom.xml \ clean install \ - -Pauth-server-wildfly \ - -Papp-server-wildfly + -Pauth-server-wildfly # Run tests - mvn -f testsuite/integration-arquillian/tests/base/pom.xml \ + mvn -f testsuite/integration-arquillian/tests/other/welcome-page/pom.xml \ clean test \ - -Dtest=WelcomePageTest \ - -Dskip.add.user.json \ -Pauth-server-wildfly diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java index 9f34a40bb8..41398b8005 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/WelcomePage.java @@ -21,6 +21,9 @@ import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.FindBy; +import static org.keycloak.testsuite.page.Form.setInputValue; +import static org.keycloak.testsuite.util.UIUtils.clickLink; + /** * @author Stian Thorgersen */ @@ -44,16 +47,11 @@ public class WelcomePage extends AuthServer { } public void setPassword(String username, String password) { - usernameInput.clear(); - usernameInput.sendKeys(username); + setInputValue(usernameInput, username); + setInputValue(passwordInput, password); + setInputValue(passwordConfirmationInput, password); - passwordInput.clear(); - passwordInput.sendKeys(password); - - passwordConfirmationInput.clear(); - passwordConfirmationInput.sendKeys(password); - - createButton.click(); + clickLink(createButton); if (!driver.getPageSource().contains("User created")) { throw new RuntimeException("Failed to updated password"); @@ -61,7 +59,7 @@ public class WelcomePage extends AuthServer { } public void navigateToAdminConsole() { - driver.findElement(By.linkText("Administration Console")).click(); + clickLink(driver.findElement(By.linkText("Administration Console"))); } } diff --git a/testsuite/integration-arquillian/tests/other/pom.xml b/testsuite/integration-arquillian/tests/other/pom.xml index 52415e05df..98d7ce94d7 100644 --- a/testsuite/integration-arquillian/tests/other/pom.xml +++ b/testsuite/integration-arquillian/tests/other/pom.xml @@ -161,6 +161,12 @@ server-config-migration + + welcome-page + + welcome-page + + diff --git a/testsuite/integration-arquillian/tests/other/welcome-page/pom.xml b/testsuite/integration-arquillian/tests/other/welcome-page/pom.xml new file mode 100644 index 0000000000..8c7b412ea8 --- /dev/null +++ b/testsuite/integration-arquillian/tests/other/welcome-page/pom.xml @@ -0,0 +1,71 @@ + + + + + + integration-arquillian-tests-other + org.keycloak.testsuite + 4.0.0.CR1-SNAPSHOT + + 4.0.0 + + integration-arquillian-tests-welcome-page + + Welcome Page tests + + + phantomjs + true + + + + + + maven-surefire-plugin + + + 60000 + + + + + maven-enforcer-plugin + + + + enforce + + + + + auth.server + (wildfly)|(eap) + Tests require activation of profile "auth-server-wildfly" or "auth-server-eap". + + + true + + + + + + + + \ No newline at end of file diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java b/testsuite/integration-arquillian/tests/other/welcome-page/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java similarity index 89% rename from testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java rename to testsuite/integration-arquillian/tests/other/welcome-page/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java index c11168e5fa..68a9c1e6c9 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java +++ b/testsuite/integration-arquillian/tests/other/welcome-page/src/test/java/org/keycloak/testsuite/welcomepage/WelcomePageTest.java @@ -38,6 +38,8 @@ import java.util.Collections; import java.util.Enumeration; import java.util.List; +import static org.keycloak.testsuite.util.URLUtils.navigateToUri; + /** * */ @@ -50,18 +52,6 @@ public class WelcomePageTest extends AbstractKeycloakTest { @Page protected OIDCLogin loginPage; - /* - * Assume adding user is skipped. - * - * Assume we are not testing migration. In migration scenario there is admin user - * migrated from previous version. - */ - @BeforeClass - public static void beforeWelcomePageTest() { - Assume.assumeTrue(Boolean.parseBoolean(System.getProperty("skip.add.user.json"))); - Assume.assumeFalse(Boolean.parseBoolean(System.getProperty("skip.welcome.page.test"))); - } - @Override public void addTestRealms(List testRealms) { // no operation @@ -119,7 +109,7 @@ public class WelcomePageTest extends AbstractKeycloakTest { @Test public void test_2_RemoteAccessNoAdmin() throws Exception { - driver.navigate().to(getPublicServerUrl()); + navigateToUri(getPublicServerUrl().toString(), true); Assert.assertFalse("Welcome page did not ask to create a new admin user.", welcomePage.isPasswordSet()); } @@ -135,7 +125,7 @@ public class WelcomePageTest extends AbstractKeycloakTest { @Test public void test_4_RemoteAccessWithAdmin() throws Exception { - driver.navigate().to(getPublicServerUrl()); + navigateToUri(getPublicServerUrl().toString(), true); Assert.assertTrue("Welcome page asked to set admin password.", welcomePage.isPasswordSet()); }