From 1b4183294654a51265904116f184438d9b97a84d Mon Sep 17 00:00:00 2001 From: vramik Date: Fri, 9 Oct 2015 13:43:16 +0200 Subject: [PATCH 01/13] fixed verifyEmail test --- .../auth/page/login/LoginActions.java | 8 ----- .../auth/page/login/VerifyEmail.java | 34 ++++++++++++++++++- .../console/page/realm/EmailSettings.java | 9 +++++ .../testsuite/account/VerifyEmailTest.java | 8 ++--- .../console/realm/LoginSettingsTest.java | 19 ++++++++--- 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/LoginActions.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/LoginActions.java index 3c3da23789..7308851522 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/LoginActions.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/LoginActions.java @@ -44,14 +44,6 @@ public class LoginActions extends AuthRealm { @FindBy(css = "span.kc-feedback-text") private WebElement feedbackText; - @FindBy(xpath = "//div[@id='kc-error-message']/p") - private WebElement error; - - public String getErrorMessage() { - waitGuiForElementPresent(error, "Error message should be visible"); - return error.getText(); - } - public String getFeedbackText() { waitGuiForElementPresent(feedbackText, "Feedback message should be visible"); return feedbackText.getText(); diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/VerifyEmail.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/VerifyEmail.java index 575ce7b18b..7a828ed329 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/VerifyEmail.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/auth/page/login/VerifyEmail.java @@ -1,9 +1,41 @@ +/* + * JBoss, Home of Professional Open Source. + * Copyright 2012, Red Hat, Inc., and individual contributors + * as indicated by the @author tags. See the copyright.txt file in the + * distribution for a full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ package org.keycloak.testsuite.auth.page.login; +import static org.keycloak.testsuite.util.WaitUtils.waitGuiForElement; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + /** * - * @author vramik + * @author Vlastislav Ramik */ public class VerifyEmail extends Authenticate { + + @FindBy(xpath = "//div[@id='kc-form-wrapper']/p") + private WebElement instruction; + public String getInstructionMessage() { + waitGuiForElement(instruction); + return instruction.getText(); + } } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/realm/EmailSettings.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/realm/EmailSettings.java index 130174ef09..a931cd60cd 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/realm/EmailSettings.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/console/page/realm/EmailSettings.java @@ -1,5 +1,6 @@ package org.keycloak.testsuite.console.page.realm; +import java.util.Map; import org.jboss.arquillian.graphene.findby.FindByJQuery; import org.jboss.arquillian.graphene.page.Page; import org.keycloak.testsuite.console.page.fragment.OnOffSwitch; @@ -66,5 +67,13 @@ public class EmailSettings extends RealmSettings { public void setFromInput(String value) { setInputValue(fromInput, value); } + + public void setSmtpServer(Map smtpServer) { + setFromInput(smtpServer.get("from")); + setHostInput(smtpServer.get("host")); + setPortInput(smtpServer.get("port")); + + save(); + } } } diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/VerifyEmailTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/VerifyEmailTest.java index 59e08cc80c..2c00ad8cf0 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/VerifyEmailTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/account/VerifyEmailTest.java @@ -49,7 +49,7 @@ public class VerifyEmailTest extends AbstractAccountManagementTest { @Before public void beforeVerifyEmail() { - // enable verify email and configure smpt server in test realm + log.info("enable verify email and configure smpt server in test realm"); RealmRepresentation testRealmRep = testRealmResource().toRepresentation(); testRealmRep.setSmtpServer(suiteContext.getSmtpServer()); testRealmRep.setVerifyEmail(true); @@ -75,11 +75,11 @@ public class VerifyEmailTest extends AbstractAccountManagementTest { assertEquals("You need to verify your email address to activate your account.", testRealmVerifyEmailPage.getFeedbackText()); - String url = assertEmailAndGetUrl(MailServerConfiguration.FROM, testUser.getEmail(), + String verifyEmailUrl = assertEmailAndGetUrl(MailServerConfiguration.FROM, testUser.getEmail(), "Someone has created a Test account with this email address."); - log.info("navigating to " + url); - driver.navigate().to(url); + log.info("navigating to url from email: " + verifyEmailUrl); + driver.navigate().to(verifyEmailUrl); assertCurrentUrlStartsWith(testRealmAccountManagementPage); testRealmAccountManagementPage.signOut(); testRealmLoginPage.form().login(testUser); diff --git a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/realm/LoginSettingsTest.java b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/realm/LoginSettingsTest.java index 13edb9dd00..94a29419f0 100644 --- a/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/realm/LoginSettingsTest.java +++ b/testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/console/realm/LoginSettingsTest.java @@ -26,6 +26,7 @@ import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD; +import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.UserRepresentation; import static org.keycloak.testsuite.admin.ApiUtil.createUserAndResetPasswordWithAdminClient; import static org.keycloak.testsuite.admin.Users.setPasswordFor; @@ -36,6 +37,7 @@ import org.keycloak.testsuite.auth.page.login.Registration; import org.keycloak.testsuite.auth.page.login.ResetCredentials; import org.keycloak.testsuite.auth.page.login.VerifyEmail; import org.keycloak.testsuite.console.page.realm.LoginSettings.RequireSSLOption; +import org.keycloak.testsuite.util.MailServer; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals; import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith; import org.openqa.selenium.Cookie; @@ -43,7 +45,6 @@ import org.openqa.selenium.Cookie; /** * * @author tkyjovsk - * @author vramik */ public class LoginSettingsTest extends AbstractRealmTest { @@ -210,15 +211,23 @@ public class LoginSettingsTest extends AbstractRealmTest { @Test public void verifyEmail() { - log.info("enabling verify email"); + MailServer.start(); + MailServer.createEmailAccount(testUser.getEmail(), "password"); + + log.info("enabling verify email in login settings"); loginSettingsPage.form().setVerifyEmailAllowed(true); loginSettingsPage.form().save(); log.debug("enabled"); + + log.info("configure smpt server in test realm"); + RealmRepresentation testRealmRep = testRealmResource().toRepresentation(); + testRealmRep.setSmtpServer(suiteContext.getSmtpServer()); + testRealmResource().update(testRealmRep); testAccountPage.navigateTo(); testRealmLoginPage.form().login(testUser); - Assert.assertEquals("Failed to send email, please try again later.", - testRealmVerifyEmailPage.getErrorMessage()); + Assert.assertEquals("An email with instructions to verify your email address has been sent to you.", + testRealmVerifyEmailPage.getInstructionMessage()); log.info("verified verify email is enabled"); @@ -241,6 +250,8 @@ public class LoginSettingsTest extends AbstractRealmTest { testAccountPage.waitForAccountLinkPresent(); log.info("verified verify email is disabled"); + + MailServer.stop(); } @Test From 2bf6f4b0fd64b92c45e30e062ee123e99f13797c Mon Sep 17 00:00:00 2001 From: Stian Thorgersen Date: Fri, 16 Oct 2015 14:03:30 +0200 Subject: [PATCH 02/13] Tweak authentication flow page a bit --- .../partials/authentication-flows.html | 34 +++++++++---------- .../keycloak/admin/resources/css/styles.css | 4 +++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/authentication-flows.html b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/authentication-flows.html index 09afda2d0d..e055978bd6 100755 --- a/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/authentication-flows.html +++ b/forms/common-themes/src/main/resources/theme/base/admin/resources/partials/authentication-flows.html @@ -26,16 +26,20 @@ Auth Type Requirement - +   - {{execution.displayName|capitalize}} + + + + {{execution.displayName|capitalize}} + -