Fix broken tests (KEYCLOAK-1857)

This commit is contained in:
dcampagna 2015-09-17 17:19:13 +02:00 committed by Stian Thorgersen
parent f7a8bbbcc8
commit fe2278b320
6 changed files with 63 additions and 21 deletions

View file

@ -6,7 +6,7 @@
${msg("loginProfileTitle")} ${msg("loginProfileTitle")}
<#elseif section = "form"> <#elseif section = "form">
<form id="kc-update-profile-form" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post"> <form id="kc-update-profile-form" class="${properties.kcFormClass!}" action="${url.loginAction}" method="post">
<#if !realm.editUsernameAllowed> <#if realm.editUsernameAllowed>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('username',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('username',properties.kcFormGroupErrorClass!)}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="username" class="${properties.kcLabelClass!}">${msg("username")}</label> <label for="username" class="${properties.kcLabelClass!}">${msg("username")}</label>

View file

@ -33,11 +33,8 @@ import org.keycloak.models.UserModel.RequiredAction;
import org.keycloak.services.managers.RealmManager; import org.keycloak.services.managers.RealmManager;
import org.keycloak.testsuite.AssertEvents; import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.OAuthClient; import org.keycloak.testsuite.OAuthClient;
import org.keycloak.testsuite.pages.AppPage; import org.keycloak.testsuite.pages.*;
import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.AppPage.RequestType;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.LoginPasswordUpdatePage;
import org.keycloak.testsuite.pages.LoginUpdateProfilePage;
import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.KeycloakRule;
import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup; import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup;
import org.keycloak.testsuite.rule.WebResource; import org.keycloak.testsuite.rule.WebResource;
@ -83,7 +80,7 @@ public class RequiredActionMultipleActionsTest {
protected LoginPasswordUpdatePage changePasswordPage; protected LoginPasswordUpdatePage changePasswordPage;
@WebResource @WebResource
protected LoginUpdateProfilePage updateProfilePage; protected LoginUpdateProfileEditUsernameAllowedPage updateProfilePage;
@Test @Test
public void updateProfileAndPassword() throws Exception { public void updateProfileAndPassword() throws Exception {

View file

@ -32,7 +32,7 @@ import org.keycloak.testsuite.AssertEvents;
import org.keycloak.testsuite.pages.AppPage; import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.AppPage.RequestType; import org.keycloak.testsuite.pages.AppPage.RequestType;
import org.keycloak.testsuite.pages.LoginPage; import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.LoginUpdateProfilePage; import org.keycloak.testsuite.pages.LoginUpdateProfileEditUsernameAllowedPage;
import org.keycloak.testsuite.rule.KeycloakRule; import org.keycloak.testsuite.rule.KeycloakRule;
import org.keycloak.testsuite.rule.WebResource; import org.keycloak.testsuite.rule.WebResource;
import org.keycloak.testsuite.rule.WebRule; import org.keycloak.testsuite.rule.WebRule;
@ -62,7 +62,7 @@ public class RequiredActionUpdateProfileTest {
protected LoginPage loginPage; protected LoginPage loginPage;
@WebResource @WebResource
protected LoginUpdateProfilePage updateProfilePage; protected LoginUpdateProfileEditUsernameAllowedPage updateProfilePage;
@Before @Before
public void before() { public void before() {

View file

@ -451,7 +451,7 @@ public abstract class AbstractIdentityProviderTest {
doAfterProviderAuthentication(); doAfterProviderAuthentication();
this.updateProfilePage.assertCurrent(); this.updateProfilePage.assertCurrent();
this.updateProfilePage.update("Test", "User", "psilva@redhat.com", "psilva"); this.updateProfilePage.update("Test", "User", "psilva@redhat.com");
WebElement element = this.driver.findElement(By.className("kc-feedback-text")); WebElement element = this.driver.findElement(By.className("kc-feedback-text"));
@ -460,7 +460,7 @@ public abstract class AbstractIdentityProviderTest {
assertEquals("Email already exists.", element.getText()); assertEquals("Email already exists.", element.getText());
this.updateProfilePage.assertCurrent(); this.updateProfilePage.assertCurrent();
this.updateProfilePage.update("Test", "User", "test-user@redhat.com", "test-user"); this.updateProfilePage.update("Test", "User", "test-user@redhat.com");
assertTrue(this.driver.getCurrentUrl().startsWith("http://localhost:8081/test-app")); assertTrue(this.driver.getCurrentUrl().startsWith("http://localhost:8081/test-app"));
@ -724,7 +724,7 @@ public abstract class AbstractIdentityProviderTest {
// update profile // update profile
this.updateProfilePage.assertCurrent(); this.updateProfilePage.assertCurrent();
this.updateProfilePage.update(userFirstName, userLastName, userEmail, username); this.updateProfilePage.update(userFirstName, userLastName, userEmail);
} }
} }

View file

@ -0,0 +1,54 @@
/*
* 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.pages;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
/**
* @author <a href="mailto:sthorger@redhat.com">Stian Thorgersen</a>
*/
public class LoginUpdateProfileEditUsernameAllowedPage extends LoginUpdateProfilePage {
@FindBy(id = "username")
private WebElement usernameInput;
public void update(String firstName, String lastName, String email, String username) {
usernameInput.clear();
usernameInput.sendKeys(username);
update(firstName, lastName, email);
}
public String getUsername() {
return usernameInput.getAttribute("value");
}
public boolean isCurrent() {
return driver.getTitle().equals("Update Account Information");
}
@Override
public void open() {
throw new UnsupportedOperationException();
}
}

View file

@ -38,24 +38,19 @@ public class LoginUpdateProfilePage extends AbstractPage {
@FindBy(id = "email") @FindBy(id = "email")
private WebElement emailInput; private WebElement emailInput;
@FindBy(id = "username")
private WebElement usernameInput;
@FindBy(css = "input[type=\"submit\"]") @FindBy(css = "input[type=\"submit\"]")
private WebElement submitButton; private WebElement submitButton;
@FindBy(className = "feedback-error") @FindBy(className = "feedback-error")
private WebElement loginErrorMessage; private WebElement loginErrorMessage;
public void update(String firstName, String lastName, String email, String username) { public void update(String firstName, String lastName, String email) {
firstNameInput.clear(); firstNameInput.clear();
firstNameInput.sendKeys(firstName); firstNameInput.sendKeys(firstName);
lastNameInput.clear(); lastNameInput.clear();
lastNameInput.sendKeys(lastName); lastNameInput.sendKeys(lastName);
emailInput.clear(); emailInput.clear();
emailInput.sendKeys(email); emailInput.sendKeys(email);
usernameInput.clear();
usernameInput.sendKeys(username);
submitButton.click(); submitButton.click();
} }
@ -75,10 +70,6 @@ public class LoginUpdateProfilePage extends AbstractPage {
return emailInput.getAttribute("value"); return emailInput.getAttribute("value");
} }
public String getUsername() {
return usernameInput.getAttribute("value");
}
public boolean isCurrent() { public boolean isCurrent() {
return driver.getTitle().equals("Update Account Information"); return driver.getTitle().equals("Update Account Information");
} }