KEYCLOAK-14915 Upgrade registration screen to PF4

This commit is contained in:
Martin Bartos 2020-10-07 10:36:06 +02:00 committed by Marek Posolda
parent 9ce2e9b1f7
commit ab347df5ee
8 changed files with 234 additions and 99 deletions

View file

@ -17,6 +17,7 @@
package org.keycloak.testsuite.auth.page; package org.keycloak.testsuite.auth.page;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.util.UIUtils; import org.keycloak.testsuite.util.UIUtils;
import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.NoSuchElementException;
@ -31,6 +32,9 @@ import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
*/ */
public class AccountFields extends FieldsBase { public class AccountFields extends FieldsBase {
@Page
private AccountErrors inputErrors;
@FindBy(id = "username") @FindBy(id = "username")
private WebElement usernameInput; private WebElement usernameInput;
@FindBy(xpath = "//label[@for='username']") @FindBy(xpath = "//label[@for='username']")
@ -119,19 +123,69 @@ public class AccountFields extends FieldsBase {
} }
public boolean hasUsernameError() { public boolean hasUsernameError() {
return hasFieldError(usernameInput); return inputErrors.getUsernameError() != null;
} }
public boolean hasEmailError() { public boolean hasEmailError() {
return hasFieldError(emailInput); return inputErrors.getEmailError() != null;
} }
public boolean hasFirstNameError() { public boolean hasFirstNameError() {
return hasFieldError(firstNameInput); return inputErrors.getFirstNameError() != null;
} }
public boolean hasLastNameError() { public boolean hasLastNameError() {
return hasFieldError(lastNameInput); return inputErrors.getLastNameError() != null;
} }
public AccountErrors getInputErrors(){
return inputErrors;
}
public static class AccountErrors{
@FindBy(id = "input-error-firstname")
private WebElement firstNameError;
@FindBy(id = "input-error-lastname")
private WebElement lastNameError;
@FindBy(id = "input-error-email")
private WebElement emailError;
@FindBy(id = "input-error-username")
private WebElement usernameError;
public String getFirstNameError() {
try {
return getTextFromElement(firstNameError);
} catch (NoSuchElementException e) {
return null;
}
}
public String getLastNameError() {
try {
return getTextFromElement(lastNameError);
} catch (NoSuchElementException e) {
return null;
}
}
public String getEmailError() {
try {
return getTextFromElement(emailError);
} catch (NoSuchElementException e) {
return null;
}
}
public String getUsernameError() {
try {
return getTextFromElement(usernameError);
} catch (NoSuchElementException e) {
return null;
}
}
}
} }

View file

@ -16,6 +16,7 @@
*/ */
package org.keycloak.testsuite.auth.page; package org.keycloak.testsuite.auth.page;
import org.jboss.arquillian.graphene.page.Page;
import org.keycloak.testsuite.util.UIUtils; import org.keycloak.testsuite.util.UIUtils;
import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
@ -29,6 +30,9 @@ import static org.keycloak.testsuite.util.UIUtils.getTextFromElement;
*/ */
public class PasswordFields extends FieldsBase { public class PasswordFields extends FieldsBase {
@Page
private PasswordErrors inputErrors;
@FindBy(id = "password") @FindBy(id = "password")
private WebElement passwordInput; private WebElement passwordInput;
@FindBy(xpath = "//label[@for='password']") @FindBy(xpath = "//label[@for='password']")
@ -84,7 +88,7 @@ public class PasswordFields extends FieldsBase {
} }
public boolean hasPasswordError() { public boolean hasPasswordError() {
return hasFieldError(passwordInput); return inputErrors.getPasswordError() != null;
} }
public boolean hasNewPasswordError() { public boolean hasNewPasswordError() {
@ -92,6 +96,35 @@ public class PasswordFields extends FieldsBase {
} }
public boolean hasConfirmPasswordError() { public boolean hasConfirmPasswordError() {
return hasFieldError(confirmPasswordInput); return inputErrors.getPasswordConfirmError() != null;
}
public PasswordErrors getInputErrors() {
return inputErrors;
}
public static class PasswordErrors {
@FindBy(id = "input-error-password")
private WebElement passwordError;
@FindBy(id = "input-error-password-confirm")
private WebElement passwordConfirmError;
public String getPasswordError() {
try {
return getTextFromElement(passwordError);
} catch (NoSuchElementException e) {
return null;
}
}
public String getPasswordConfirmError() {
try {
return getTextFromElement(passwordConfirmError);
} catch (NoSuchElementException e) {
return null;
}
}
} }
} }

View file

@ -17,7 +17,11 @@
package org.keycloak.testsuite.pages; package org.keycloak.testsuite.pages;
import org.jboss.arquillian.graphene.page.Page;
import org.junit.Assert; import org.junit.Assert;
import org.keycloak.testsuite.auth.page.AccountFields;
import org.keycloak.testsuite.auth.page.PasswordFields;
import org.keycloak.testsuite.util.UIUtils;
import org.openqa.selenium.NoSuchElementException; import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy; import org.openqa.selenium.support.FindBy;
@ -27,6 +31,12 @@ import org.openqa.selenium.support.FindBy;
*/ */
public class RegisterPage extends AbstractPage { public class RegisterPage extends AbstractPage {
@Page
private AccountFields.AccountErrors accountErrors;
@Page
private PasswordFields.PasswordErrors passwordErrors;
@FindBy(id = "firstName") @FindBy(id = "firstName")
private WebElement firstNameInput; private WebElement firstNameInput;
@ -49,7 +59,7 @@ public class RegisterPage extends AbstractPage {
private WebElement submitButton; private WebElement submitButton;
@FindBy(className = "alert-error") @FindBy(className = "alert-error")
private WebElement loginErrorMessage; private WebElement loginAlertErrorMessage;
@FindBy(className = "instruction") @FindBy(className = "instruction")
private WebElement loginInstructionMessage; private WebElement loginInstructionMessage;
@ -132,13 +142,17 @@ public class RegisterPage extends AbstractPage {
backToLoginLink.click(); backToLoginLink.click();
} }
public String getError() { public String getAlertError() {
return loginErrorMessage != null ? loginErrorMessage.getText() : null; try {
return UIUtils.getTextFromElement(loginAlertErrorMessage);
} catch (NoSuchElementException e) {
return null;
}
} }
public String getInstruction() { public String getInstruction() {
try { try {
return loginInstructionMessage != null ? loginInstructionMessage.getText() : null; return UIUtils.getTextFromElement(loginInstructionMessage);
} catch (NoSuchElementException e){ } catch (NoSuchElementException e){
// OK // OK
} }
@ -173,6 +187,14 @@ public class RegisterPage extends AbstractPage {
return PageUtils.getPageTitle(driver).equals("Register"); return PageUtils.getPageTitle(driver).equals("Register");
} }
public AccountFields.AccountErrors getInputAccountErrors(){
return accountErrors;
}
public PasswordFields.PasswordErrors getInputPasswordErrors(){
return passwordErrors;
}
@Override @Override
public void open() { public void open() {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();

View file

@ -243,7 +243,7 @@ public class LDAPMSADFullNameTest extends AbstractLDAPTest {
registerPage.assertCurrent(); registerPage.assertCurrent();
registerPage.register("John", "Existing", "johnyanth@check.cz", "existingkc", "Password1", "Password1"); registerPage.register("John", "Existing", "johnyanth@check.cz", "existingkc", "Password1", "Password1");
Assert.assertEquals("Username already exists.", registerPage.getError()); Assert.assertEquals("Username already exists.", registerPage.getInputAccountErrors().getUsernameError());
registerPage.register("John", "Existing", "johnyanth@check.cz", "existingkc2", "Password1", "Password1"); registerPage.register("John", "Existing", "johnyanth@check.cz", "existingkc2", "Password1", "Password1");
appPage.logout(); appPage.logout();

View file

@ -426,12 +426,12 @@ public class LDAPProvidersIntegrationTest extends AbstractLDAPTest {
// check existing username // check existing username
registerPage.register("firstName", "lastName", "email@mail.cz", "existing", "Password1", "Password1"); registerPage.register("firstName", "lastName", "email@mail.cz", "existing", "Password1", "Password1");
registerPage.assertCurrent(); registerPage.assertCurrent();
Assert.assertEquals("Username already exists.", registerPage.getError()); Assert.assertEquals("Username already exists.", registerPage.getInputAccountErrors().getUsernameError());
// Check existing email // Check existing email
registerPage.register("firstName", "lastName", "existing@email.org", "nonExisting", "Password1", "Password1"); registerPage.register("firstName", "lastName", "existing@email.org", "nonExisting", "Password1", "Password1");
registerPage.assertCurrent(); registerPage.assertCurrent();
Assert.assertEquals("Email already exists.", registerPage.getError()); Assert.assertEquals("Email already exists.", registerPage.getInputAccountErrors().getEmailError());
} }

View file

@ -81,7 +81,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerExistingUser@email", "roleRichUser", "password", "password"); registerPage.register("firstName", "lastName", "registerExistingUser@email", "roleRichUser", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Username already exists.", registerPage.getError()); assertEquals("Username already exists.", registerPage.getInputAccountErrors().getUsernameError());
// assert form keeps form fields on error // assert form keeps form fields on error
assertEquals("firstName", registerPage.getFirstName()); assertEquals("firstName", registerPage.getFirstName());
@ -105,7 +105,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "test-user@localhost", "registerExistingUser", "password", "password"); registerPage.register("firstName", "lastName", "test-user@localhost", "registerExistingUser", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Email already exists.", registerPage.getError()); assertEquals("Email already exists.", registerPage.getInputAccountErrors().getEmailError());
// assert form keeps form fields on error // assert form keeps form fields on error
assertEquals("firstName", registerPage.getFirstName()); assertEquals("firstName", registerPage.getFirstName());
@ -155,7 +155,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerUserInvalidPasswordConfirm@email", "registerUserInvalidPasswordConfirm", "password", "invalid"); registerPage.register("firstName", "lastName", "registerUserInvalidPasswordConfirm@email", "registerUserInvalidPasswordConfirm", "password", "invalid");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Password confirmation doesn't match.", registerPage.getError()); assertEquals("Password confirmation doesn't match.", registerPage.getInputPasswordErrors().getPasswordConfirmError());
// assert form keeps form fields on error // assert form keeps form fields on error
assertEquals("firstName", registerPage.getFirstName()); assertEquals("firstName", registerPage.getFirstName());
@ -180,7 +180,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerUserMissingPassword@email", "registerUserMissingPassword", null, null); registerPage.register("firstName", "lastName", "registerUserMissingPassword@email", "registerUserMissingPassword", null, null);
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Please specify password.", registerPage.getError()); assertEquals("Please specify password.", registerPage.getInputPasswordErrors().getPasswordError());
events.expectRegister("registerUserMissingPassword", "registerUserMissingPassword@email") events.expectRegister("registerUserMissingPassword", "registerUserMissingPassword@email")
.removeDetail(Details.USERNAME) .removeDetail(Details.USERNAME)
@ -208,7 +208,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerPasswordPolicy@email", "registerPasswordPolicy", "pass", "pass"); registerPage.register("firstName", "lastName", "registerPasswordPolicy@email", "registerPasswordPolicy", "pass", "pass");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Invalid password: minimum length 8.", registerPage.getError()); assertEquals("Invalid password: minimum length 8.", registerPage.getInputPasswordErrors().getPasswordError());
events.expectRegister("registerPasswordPolicy", "registerPasswordPolicy@email") events.expectRegister("registerPasswordPolicy", "registerPasswordPolicy@email")
.removeDetail(Details.USERNAME) .removeDetail(Details.USERNAME)
@ -240,7 +240,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerUserMissingUsername@email", null, "password", "password"); registerPage.register("firstName", "lastName", "registerUserMissingUsername@email", null, "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Please specify username.", registerPage.getError()); assertEquals("Please specify username.", registerPage.getInputAccountErrors().getUsernameError());
events.expectRegister(null, "registerUserMissingUsername@email") events.expectRegister(null, "registerUserMissingUsername@email")
.removeDetail(Details.USERNAME) .removeDetail(Details.USERNAME)
@ -258,11 +258,11 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Please specify username.\n" + assertEquals("Please specify username.", registerPage.getInputAccountErrors().getUsernameError());
"Please specify first name.\n" + assertEquals("Please specify first name.", registerPage.getInputAccountErrors().getFirstNameError());
"Please specify last name.\n" + assertEquals("Please specify last name.", registerPage.getInputAccountErrors().getLastNameError());
"Please specify email.\n" + assertEquals("Please specify email.", registerPage.getInputAccountErrors().getEmailError());
"Please specify password.", registerPage.getError()); assertEquals("Please specify password.", registerPage.getInputPasswordErrors().getPasswordError());
events.expectRegister(null, "registerUserMissingUsername@email") events.expectRegister(null, "registerUserMissingUsername@email")
.removeDetail(Details.USERNAME) .removeDetail(Details.USERNAME)
@ -278,7 +278,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", null, "registerUserMissingEmail", "password", "password"); registerPage.register("firstName", "lastName", null, "registerUserMissingEmail", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Please specify email.", registerPage.getError()); assertEquals("Please specify email.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister("registerUserMissingEmail", null) events.expectRegister("registerUserMissingEmail", null)
.removeDetail("email") .removeDetail("email")
.error("invalid_registration").assertEvent(); .error("invalid_registration").assertEvent();
@ -293,7 +293,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerUserInvalidEmailemail", "registerUserInvalidEmail", "password", "password"); registerPage.register("firstName", "lastName", "registerUserInvalidEmailemail", "registerUserInvalidEmail", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("registerUserInvalidEmailemail", registerPage.getEmail()); assertEquals("registerUserInvalidEmailemail", registerPage.getEmail());
assertEquals("Invalid email address.", registerPage.getError()); assertEquals("Invalid email address.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister("registerUserInvalidEmail", "registerUserInvalidEmailemail") events.expectRegister("registerUserInvalidEmail", "registerUserInvalidEmailemail")
.error("invalid_registration").assertEvent(); .error("invalid_registration").assertEvent();
} }
@ -480,19 +480,19 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername"); registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername");
assertTrue(registerPage.isCurrent()); assertTrue(registerPage.isCurrent());
assertEquals("Invalid password: must not be equal to the username.", registerPage.getError()); assertEquals("Invalid password: must not be equal to the username.", registerPage.getInputPasswordErrors().getPasswordError());
adminClient.realm("test").users().create(UserBuilder.create().username("registerUserNotUsername").build()); adminClient.realm("test").users().create(UserBuilder.create().username("registerUserNotUsername").build());
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername"); registerPage.register("firstName", "lastName", "registerUserNotUsername@email", "registerUserNotUsername", "registerUserNotUsername", "registerUserNotUsername");
assertTrue(registerPage.isCurrent()); assertTrue(registerPage.isCurrent());
assertEquals("Username already exists.", registerPage.getError()); assertEquals("Username already exists.", registerPage.getInputAccountErrors().getUsernameError());
registerPage.register("firstName", "lastName", "registerUserNotUsername@email", null, "password", "password"); registerPage.register("firstName", "lastName", "registerUserNotUsername@email", null, "password", "password");
assertTrue(registerPage.isCurrent()); assertTrue(registerPage.isCurrent());
assertEquals("Please specify username.", registerPage.getError()); assertEquals("Please specify username.", registerPage.getInputAccountErrors().getUsernameError());
} }
// KEYCLOAK-12729 // KEYCLOAK-12729
@ -514,7 +514,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserNotEmail@email", "registerUserNotEmail@email", "registerUserNotEmail@email"); registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserNotEmail@email", "registerUserNotEmail@email", "registerUserNotEmail@email");
assertTrue(registerPage.isCurrent()); assertTrue(registerPage.isCurrent());
assertEquals("Invalid password: must not be equal to the email.", registerPage.getError()); assertEquals("Invalid password: must not be equal to the email.", registerPage.getInputPasswordErrors().getPasswordError());
} finally { } finally {
configureRealmRegistrationEmailAsUsername(false); configureRealmRegistrationEmailAsUsername(false);
} }
@ -536,7 +536,7 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.registerWithEmailAsUsername("firstName", "lastName", "test-user@localhost", "password", "password"); registerPage.registerWithEmailAsUsername("firstName", "lastName", "test-user@localhost", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Email already exists.", registerPage.getError()); assertEquals("Email already exists.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister("test-user@localhost", "test-user@localhost").user((String) null).error("email_in_use").assertEvent(); events.expectRegister("test-user@localhost", "test-user@localhost").user((String) null).error("email_in_use").assertEvent();
} finally { } finally {
@ -555,12 +555,12 @@ public class RegisterTest extends AbstractTestRealmKeycloakTest {
registerPage.registerWithEmailAsUsername("firstName", "lastName", null, "password", "password"); registerPage.registerWithEmailAsUsername("firstName", "lastName", null, "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Please specify email.", registerPage.getError()); assertEquals("Please specify email.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister(null, null).removeDetail("username").removeDetail("email").error("invalid_registration").assertEvent(); events.expectRegister(null, null).removeDetail("username").removeDetail("email").error("invalid_registration").assertEvent();
registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserInvalidEmailemail", "password", "password"); registerPage.registerWithEmailAsUsername("firstName", "lastName", "registerUserInvalidEmailemail", "password", "password");
registerPage.assertCurrent(); registerPage.assertCurrent();
assertEquals("Invalid email address.", registerPage.getError()); assertEquals("Invalid email address.", registerPage.getInputAccountErrors().getEmailError());
events.expectRegister("registerUserInvalidEmailemail", "registerUserInvalidEmailemail").error("invalid_registration").assertEvent(); events.expectRegister("registerUserInvalidEmailemail", "registerUserInvalidEmailemail").error("invalid_registration").assertEvent();
} finally { } finally {
configureRealmRegistrationEmailAsUsername(false); configureRealmRegistrationEmailAsUsername(false);

View file

@ -217,64 +217,35 @@ public class LoginPageTest extends AbstractLoginTest {
private void assertRegistrationFields(String firstName, String lastName, String email, String username, boolean password, boolean passwordConfirm) { private void assertRegistrationFields(String firstName, String lastName, String email, String username, boolean password, boolean passwordConfirm) {
assertTrue(registrationPage.feedbackMessage().isError()); assertTrue(registrationPage.feedbackMessage().isError());
final String errorMsg = registrationPage.feedbackMessage().getText();
if (firstName != null) { assertRegistrationAvailability(firstName != null, registrationPage.accountFields().hasFirstNameError(),
assertEquals(firstName, registrationPage.accountFields().getFirstName()); firstName, registrationPage.accountFields().getFirstName());
assertFalse(registrationPage.accountFields().hasFirstNameError());
assertFalse(errorMsg.contains("first name")); assertRegistrationAvailability(lastName != null, registrationPage.accountFields().hasLastNameError(),
} lastName, registrationPage.accountFields().getLastName());
else {
assertTrue(registrationPage.accountFields().hasFirstNameError()); assertRegistrationAvailability(email != null, registrationPage.accountFields().hasEmailError(),
assertTrue(errorMsg.contains("first name")); email, registrationPage.accountFields().getEmail());
assertRegistrationAvailability(username != null, registrationPage.accountFields().hasUsernameError(),
username, registrationPage.accountFields().getUsername());
assertRegistrationAvailability(password, registrationPage.passwordFields().hasPasswordError());
assertRegistrationAvailability(passwordConfirm, registrationPage.passwordFields().hasConfirmPasswordError());
} }
if (lastName != null) { private void assertRegistrationAvailability(boolean isAvailable, boolean state) {
assertEquals(lastName, registrationPage.accountFields().getLastName()); assertRegistrationAvailability(isAvailable, state, null, null);
assertFalse(registrationPage.accountFields().hasLastNameError());
assertFalse(errorMsg.contains("last name"));
}
else {
assertTrue(registrationPage.accountFields().hasLastNameError());
assertTrue(errorMsg.contains("last name"));
} }
if (email != null) { private void assertRegistrationAvailability(boolean isAvailable, boolean state, String expected, String actual) {
assertEquals(email, registrationPage.accountFields().getEmail()); if (isAvailable) {
assertFalse(registrationPage.accountFields().hasEmailError()); assertFalse(state);
assertFalse(errorMsg.contains("email")); if (expected != null && actual != null) {
assertEquals(expected, actual);
} }
else { } else {
assertTrue(registrationPage.accountFields().hasEmailError()); assertTrue(state);
assertTrue(errorMsg.contains("email"));
}
if (username != null) {
assertEquals(username, registrationPage.accountFields().getUsername());
assertFalse(registrationPage.accountFields().hasUsernameError());
assertFalse(errorMsg.contains("username"));
}
else {
assertTrue(registrationPage.accountFields().hasUsernameError());
assertTrue(errorMsg.contains("username"));
}
if (password) {
assertFalse(registrationPage.passwordFields().hasPasswordError());
assertFalse(errorMsg.contains("Please specify password."));
}
else {
assertTrue(registrationPage.passwordFields().hasPasswordError());
assertTrue(errorMsg.contains("Please specify password."));
}
if (passwordConfirm) {
assertFalse(registrationPage.passwordFields().hasConfirmPasswordError());
assertFalse(registrationPage.feedbackMessage().getText().contains("Password confirmation doesn't match."));
}
else {
assertTrue(registrationPage.passwordFields().hasConfirmPasswordError());
assertTrue(registrationPage.feedbackMessage().getText().contains("Password confirmation doesn't match."));
} }
} }

View file

@ -1,63 +1,118 @@
<#import "template.ftl" as layout> <#import "template.ftl" as layout>
<@layout.registrationLayout; section> <@layout.registrationLayout displayMessage=!messagesPerField.existsError('firstName','lastName','email','username','password','password-confirm'); section>
<#if section = "header"> <#if section = "header">
${msg("registerTitle")} ${msg("registerTitle")}
<#elseif section = "form"> <#elseif section = "form">
<form id="kc-register-form" class="${properties.kcFormClass!}" action="${url.registrationAction}" method="post"> <form id="kc-register-form" class="${properties.kcFormClass!}" action="${url.registrationAction}" method="post">
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('firstName',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="firstName" class="${properties.kcLabelClass!}">${msg("firstName")}</label> <label for="firstName" class="${properties.kcLabelClass!}">${msg("firstName")}</label>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="text" id="firstName" class="${properties.kcInputClass!}" name="firstName" value="${(register.formData.firstName!'')}" /> <input type="text" id="firstName" class="${properties.kcInputClass!}" name="firstName"
value="${(register.formData.firstName!'')}"
aria-invalid="<#if messagesPerField.existsError('firstName')>true</#if>"
/>
<#if messagesPerField.existsError('firstName')>
<span id="input-error-firstname" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('firstName'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('lastName',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="lastName" class="${properties.kcLabelClass!}">${msg("lastName")}</label> <label for="lastName" class="${properties.kcLabelClass!}">${msg("lastName")}</label>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="text" id="lastName" class="${properties.kcInputClass!}" name="lastName" value="${(register.formData.lastName!'')}" /> <input type="text" id="lastName" class="${properties.kcInputClass!}" name="lastName"
value="${(register.formData.lastName!'')}"
aria-invalid="<#if messagesPerField.existsError('lastName')>true</#if>"
/>
<#if messagesPerField.existsError('lastName')>
<span id="input-error-lastname" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('lastName'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('email',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="email" class="${properties.kcLabelClass!}">${msg("email")}</label> <label for="email" class="${properties.kcLabelClass!}">${msg("email")}</label>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="text" id="email" class="${properties.kcInputClass!}" name="email" value="${(register.formData.email!'')}" autocomplete="email" /> <input type="text" id="email" class="${properties.kcInputClass!}" name="email"
value="${(register.formData.email!'')}" autocomplete="email"
aria-invalid="<#if messagesPerField.existsError('email')>true</#if>"
/>
<#if messagesPerField.existsError('email')>
<span id="input-error-email" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('email'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
<#if !realm.registrationEmailAsUsername> <#if !realm.registrationEmailAsUsername>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('username',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<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>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="text" id="username" class="${properties.kcInputClass!}" name="username" value="${(register.formData.username!'')}" autocomplete="username" /> <input type="text" id="username" class="${properties.kcInputClass!}" name="username"
value="${(register.formData.username!'')}" autocomplete="username"
aria-invalid="<#if messagesPerField.existsError('username')>true</#if>"
/>
<#if messagesPerField.existsError('username')>
<span id="input-error-username" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('username'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
</#if> </#if>
<#if passwordRequired??> <#if passwordRequired??>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('password',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="password" class="${properties.kcLabelClass!}">${msg("password")}</label> <label for="password" class="${properties.kcLabelClass!}">${msg("password")}</label>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="password" id="password" class="${properties.kcInputClass!}" name="password" autocomplete="new-password"/> <input type="password" id="password" class="${properties.kcInputClass!}" name="password"
autocomplete="new-password"
aria-invalid="<#if messagesPerField.existsError('password','password-confirm')>true</#if>"
/>
<#if messagesPerField.existsError('password')>
<span id="input-error-password" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
<div class="${properties.kcFormGroupClass!} ${messagesPerField.printIfExists('password-confirm',properties.kcFormGroupErrorClass!)}"> <div class="${properties.kcFormGroupClass!}">
<div class="${properties.kcLabelWrapperClass!}"> <div class="${properties.kcLabelWrapperClass!}">
<label for="password-confirm" class="${properties.kcLabelClass!}">${msg("passwordConfirm")}</label> <label for="password-confirm"
class="${properties.kcLabelClass!}">${msg("passwordConfirm")}</label>
</div> </div>
<div class="${properties.kcInputWrapperClass!}"> <div class="${properties.kcInputWrapperClass!}">
<input type="password" id="password-confirm" class="${properties.kcInputClass!}" name="password-confirm" /> <input type="password" id="password-confirm" class="${properties.kcInputClass!}"
name="password-confirm"
aria-invalid="<#if messagesPerField.existsError('password-confirm')>true</#if>"
/>
<#if messagesPerField.existsError('password-confirm')>
<span id="input-error-password-confirm" class="${properties.kcInputErrorMessageClass!}" aria-live="polite">
${kcSanitize(messagesPerField.get('password-confirm'))?no_esc}
</span>
</#if>
</div> </div>
</div> </div>
</#if> </#if>