Merge pull request #1952 from vmuzikar/ui-stability
KEYCLOAK-1865 Fix stability of some UI arquillian tests
This commit is contained in:
commit
1afd3d422c
8 changed files with 129 additions and 153 deletions
|
@ -43,40 +43,40 @@ public class CreateClientMappersForm extends Form {
|
||||||
@FindBy(id = "mapperTypeCreate")
|
@FindBy(id = "mapperTypeCreate")
|
||||||
private Select mapperTypeSelect;
|
private Select mapperTypeSelect;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Property']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Property']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement propertyInput;
|
private WebElement propertyInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='User Attribute']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='User Attribute']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement userAttributeInput;
|
private WebElement userAttributeInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='User Session Note']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='User Session Note']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement userSessionNoteInput;
|
private WebElement userSessionNoteInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Multivalued']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Multivalued']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch multivaluedInput;
|
private OnOffSwitch multivaluedInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//button[text() = 'Select Role']/../..//input")
|
@FindBy(xpath = ".//button[text() = 'Select Role']/../..//input")
|
||||||
private WebElement roleInput;
|
private WebElement roleInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='New Role Name']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='New Role Name']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement newRoleInput;
|
private WebElement newRoleInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Token Claim Name']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Token Claim Name']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement tokenClaimNameInput;
|
private WebElement tokenClaimNameInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Claim value']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Claim value']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement tokenClaimValueInput;
|
private WebElement tokenClaimValueInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Claim JSON Type']//following-sibling::node()//select")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Claim JSON Type']//following-sibling::node()//select")
|
||||||
private Select claimJSONTypeInput;
|
private Select claimJSONTypeInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Add to ID token']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Add to ID token']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch addToIDTokenInput;
|
private OnOffSwitch addToIDTokenInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Add to access token']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Add to access token']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch addToAccessTokenInput;
|
private OnOffSwitch addToAccessTokenInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Full group path']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Full group path']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch fullGroupPath;
|
private OnOffSwitch fullGroupPath;
|
||||||
|
|
||||||
@FindBy(xpath = ".//button[text() = 'Select Role']")
|
@FindBy(xpath = ".//button[text() = 'Select Role']")
|
||||||
|
@ -260,25 +260,25 @@ public class CreateClientMappersForm extends Form {
|
||||||
}
|
}
|
||||||
|
|
||||||
//SAML
|
//SAML
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Role attribute name']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Role attribute name']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement roleAttributeNameInput;
|
private WebElement roleAttributeNameInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Friendly Name']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Friendly Name']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement friendlyNameInput;
|
private WebElement friendlyNameInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='SAML Attribute NameFormat']//following-sibling::node()//select")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='SAML Attribute NameFormat']//following-sibling::node()//select")
|
||||||
private Select samlAttributeNameFormatSelect;
|
private Select samlAttributeNameFormatSelect;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Single Role Attribute']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Single Role Attribute']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch singleRoleAttributeSwitch;
|
private OnOffSwitch singleRoleAttributeSwitch;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Attribute value']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Attribute value']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement attributeValueInput;
|
private WebElement attributeValueInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Group attribute name']//following-sibling::node()//input[@type='text']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Group attribute name']//following-sibling::node()//input[@type='text']")
|
||||||
private WebElement groupAttributeNameInput;
|
private WebElement groupAttributeNameInput;
|
||||||
|
|
||||||
@FindBy(xpath = ".//div[@properties='mapperType.properties']//label[text()='Single Group Attribute']//following-sibling::node()//div[@class='onoffswitch']")
|
@FindBy(xpath = ".//div[@properties='model.mapperType.properties']//label[text()='Single Group Attribute']//following-sibling::node()//div[@class='onoffswitch']")
|
||||||
private OnOffSwitch singleGroupAttributeSwitch;
|
private OnOffSwitch singleGroupAttributeSwitch;
|
||||||
|
|
||||||
public void setRoleAttributeName(String value) {
|
public void setRoleAttributeName(String value) {
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class BruteForceDetection extends SecurityDefenses {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWaitIncrementSelect(TimeSelectValues value) {
|
public void setWaitIncrementSelect(TimeSelectValues value) {
|
||||||
waitIncrementSelect.selectByVisibleText(value.getName());
|
waitIncrementSelect.selectByValue(value.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setQuickLoginCheckInput(String value) {
|
public void setQuickLoginCheckInput(String value) {
|
||||||
|
@ -85,7 +85,7 @@ public class BruteForceDetection extends SecurityDefenses {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMinQuickLoginWaitSelect(TimeSelectValues value) {
|
public void setMinQuickLoginWaitSelect(TimeSelectValues value) {
|
||||||
minQuickLoginWaitSelect.selectByVisibleText(value.getName());
|
minQuickLoginWaitSelect.selectByValue(value.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxWaitInput(String value) {
|
public void setMaxWaitInput(String value) {
|
||||||
|
@ -93,7 +93,7 @@ public class BruteForceDetection extends SecurityDefenses {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxWaitSelect(TimeSelectValues value) {
|
public void setMaxWaitSelect(TimeSelectValues value) {
|
||||||
maxWaitSelect.selectByVisibleText(value.getName());
|
maxWaitSelect.selectByValue(value.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFailureResetTimeInput(String value) {
|
public void setFailureResetTimeInput(String value) {
|
||||||
|
@ -101,7 +101,7 @@ public class BruteForceDetection extends SecurityDefenses {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFailureResetTimeSelect(TimeSelectValues value) {
|
public void setFailureResetTimeSelect(TimeSelectValues value) {
|
||||||
failureResetTimeSelect.selectByVisibleText(value.getName());
|
failureResetTimeSelect.selectByValue(value.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,6 +80,10 @@ public class LoginSettings extends RealmSettings {
|
||||||
public void setEmailAsUsername(boolean emailAsUsername) {
|
public void setEmailAsUsername(boolean emailAsUsername) {
|
||||||
emailAsUsernameOnOffSwitch.setOn(emailAsUsername);
|
emailAsUsernameOnOffSwitch.setOn(emailAsUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEmailAsUsername() {
|
||||||
|
return emailAsUsernameOnOffSwitch.isOn();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEditUsernameAllowed() {
|
public boolean isEditUsernameAllowed() {
|
||||||
return editUsernameAllowed.isOn();
|
return editUsernameAllowed.isOn();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.keycloak.testsuite.console.page.fragment.OnOffSwitch;
|
||||||
import static org.keycloak.testsuite.page.Form.setInputValue;
|
import static org.keycloak.testsuite.page.Form.setInputValue;
|
||||||
import org.openqa.selenium.WebElement;
|
import org.openqa.selenium.WebElement;
|
||||||
import org.openqa.selenium.support.FindBy;
|
import org.openqa.selenium.support.FindBy;
|
||||||
|
import static org.keycloak.testsuite.util.WaitUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -25,7 +26,7 @@ public class UserCredentials extends User {
|
||||||
@FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='temporaryPassword']]")
|
@FindBy(xpath = ".//div[@class='onoffswitch' and ./input[@id='temporaryPassword']]")
|
||||||
private OnOffSwitch temporaryOnOffSwitch;
|
private OnOffSwitch temporaryOnOffSwitch;
|
||||||
|
|
||||||
@FindBy(xpath = ".//button[contains(@data-ng-click, 'resetPassword')]")
|
@FindBy(xpath = ".//div[not(contains(@class, 'ng-hide'))]/button[contains(@data-ng-click, 'resetPassword')]")
|
||||||
private WebElement resetPasswordButton;
|
private WebElement resetPasswordButton;
|
||||||
|
|
||||||
public void setNewPassword(String newPassword) {
|
public void setNewPassword(String newPassword) {
|
||||||
|
@ -41,6 +42,7 @@ public class UserCredentials extends User {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clickResetPasswordAndConfirm() {
|
public void clickResetPasswordAndConfirm() {
|
||||||
|
waitUntilElement(resetPasswordButton);
|
||||||
resetPasswordButton.click();
|
resetPasswordButton.click();
|
||||||
modalDialog.ok();
|
modalDialog.ok();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,9 @@ public class Form {
|
||||||
|
|
||||||
public static final String ACTIVE_DIV_XPATH = ".//div[not(contains(@class,'ng-hide'))]";
|
public static final String ACTIVE_DIV_XPATH = ".//div[not(contains(@class,'ng-hide'))]";
|
||||||
|
|
||||||
@FindBy(xpath = ACTIVE_DIV_XPATH + "/button[text()='Save']")
|
@FindBy(xpath = ACTIVE_DIV_XPATH + "/button[@kc-save or @data-kc-save]")
|
||||||
private WebElement save;
|
private WebElement save;
|
||||||
@FindBy(xpath = ACTIVE_DIV_XPATH + "/button[text()='Cancel']")
|
@FindBy(xpath = ACTIVE_DIV_XPATH + "/button[@kc-reset or @data-kc-reset]")
|
||||||
private WebElement cancel;
|
private WebElement cancel;
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.junit.Assert;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
||||||
import org.keycloak.representations.idm.RealmRepresentation;
|
import org.keycloak.representations.idm.RealmRepresentation;
|
||||||
|
@ -41,13 +40,13 @@ import org.keycloak.testsuite.console.page.realm.LoginSettings.RequireSSLOption;
|
||||||
import org.keycloak.testsuite.util.MailServer;
|
import org.keycloak.testsuite.util.MailServer;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlEquals;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
||||||
|
|
||||||
import org.openqa.selenium.Cookie;
|
import org.openqa.selenium.Cookie;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author tkyjovsk
|
* @author tkyjovsk
|
||||||
*/
|
*/
|
||||||
@Ignore
|
|
||||||
public class LoginSettingsTest extends AbstractRealmTest {
|
public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
|
|
||||||
private static final String NEW_USERNAME = "newUsername";
|
private static final String NEW_USERNAME = "newUsername";
|
||||||
|
@ -84,7 +83,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
|
|
||||||
log.info("enabling registration");
|
log.info("enabling registration");
|
||||||
loginSettingsPage.form().setRegistrationAllowed(true);
|
loginSettingsPage.form().setRegistrationAllowed(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isRegistrationAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -98,7 +99,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("enabling email as username");
|
log.info("enabling email as username");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setEmailAsUsername(true);
|
loginSettingsPage.form().setEmailAsUsername(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isEmailAsUsername());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -112,8 +115,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("disabling registration");
|
log.info("disabling registration");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setRegistrationAllowed(false);
|
loginSettingsPage.form().setRegistrationAllowed(false);
|
||||||
loginSettingsPage.form().save();
|
|
||||||
assertFalse(loginSettingsPage.form().isRegistrationAllowed());
|
assertFalse(loginSettingsPage.form().isRegistrationAllowed());
|
||||||
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("disabled");
|
log.debug("disabled");
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -125,7 +129,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
public void editUsername() {
|
public void editUsername() {
|
||||||
log.info("enabling edit username");
|
log.info("enabling edit username");
|
||||||
loginSettingsPage.form().setEditUsernameAllowed(true);
|
loginSettingsPage.form().setEditUsernameAllowed(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isEditUsernameAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
log.info("edit username");
|
log.info("edit username");
|
||||||
|
@ -145,7 +151,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("disabling edit username");
|
log.info("disabling edit username");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setEditUsernameAllowed(false);
|
loginSettingsPage.form().setEditUsernameAllowed(false);
|
||||||
|
assertFalse(loginSettingsPage.form().isEditUsernameAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("disabled");
|
log.debug("disabled");
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +164,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
|
|
||||||
log.info("enabling reset password");
|
log.info("enabling reset password");
|
||||||
loginSettingsPage.form().setResetPasswordAllowed(true);
|
loginSettingsPage.form().setResetPasswordAllowed(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isResetPasswordAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -169,8 +179,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("disabling reset password");
|
log.info("disabling reset password");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setResetPasswordAllowed(false);
|
loginSettingsPage.form().setResetPasswordAllowed(false);
|
||||||
loginSettingsPage.form().save();
|
|
||||||
assertFalse(loginSettingsPage.form().isResetPasswordAllowed());
|
assertFalse(loginSettingsPage.form().isResetPasswordAllowed());
|
||||||
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("disabled");
|
log.debug("disabled");
|
||||||
|
|
||||||
testRealmAdminConsolePage.navigateTo();
|
testRealmAdminConsolePage.navigateTo();
|
||||||
|
@ -183,7 +194,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
|
|
||||||
log.info("enabling remember me");
|
log.info("enabling remember me");
|
||||||
loginSettingsPage.form().setRememberMeAllowed(true);
|
loginSettingsPage.form().setRememberMeAllowed(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isRememberMeAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
log.info("login with remember me checked");
|
log.info("login with remember me checked");
|
||||||
|
@ -198,8 +211,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("disabling remember me");
|
log.info("disabling remember me");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setRememberMeAllowed(false);
|
loginSettingsPage.form().setRememberMeAllowed(false);
|
||||||
loginSettingsPage.form().save();
|
|
||||||
assertFalse(loginSettingsPage.form().isRememberMeAllowed());
|
assertFalse(loginSettingsPage.form().isRememberMeAllowed());
|
||||||
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("disabled");
|
log.debug("disabled");
|
||||||
|
|
||||||
testAccountPage.navigateTo();
|
testAccountPage.navigateTo();
|
||||||
|
@ -218,10 +232,12 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
|
|
||||||
log.info("enabling verify email in login settings");
|
log.info("enabling verify email in login settings");
|
||||||
loginSettingsPage.form().setVerifyEmailAllowed(true);
|
loginSettingsPage.form().setVerifyEmailAllowed(true);
|
||||||
|
assertTrue(loginSettingsPage.form().isVerifyEmailAllowed());
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("enabled");
|
log.debug("enabled");
|
||||||
|
|
||||||
log.info("configure smpt server in test realm");
|
log.info("configure smtp server in test realm");
|
||||||
RealmRepresentation testRealmRep = testRealmResource().toRepresentation();
|
RealmRepresentation testRealmRep = testRealmResource().toRepresentation();
|
||||||
testRealmRep.setSmtpServer(suiteContext.getSmtpServer());
|
testRealmRep.setSmtpServer(suiteContext.getSmtpServer());
|
||||||
testRealmResource().update(testRealmRep);
|
testRealmResource().update(testRealmRep);
|
||||||
|
@ -236,8 +252,9 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("disabling verify email");
|
log.info("disabling verify email");
|
||||||
loginSettingsPage.navigateTo();
|
loginSettingsPage.navigateTo();
|
||||||
loginSettingsPage.form().setVerifyEmailAllowed(false);
|
loginSettingsPage.form().setVerifyEmailAllowed(false);
|
||||||
loginSettingsPage.form().save();
|
|
||||||
assertFalse(loginSettingsPage.form().isVerifyEmailAllowed());
|
assertFalse(loginSettingsPage.form().isVerifyEmailAllowed());
|
||||||
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("disabled");
|
log.debug("disabled");
|
||||||
|
|
||||||
log.debug("create new test user");
|
log.debug("create new test user");
|
||||||
|
@ -261,6 +278,7 @@ public class LoginSettingsTest extends AbstractRealmTest {
|
||||||
log.info("set require ssl for all requests");
|
log.info("set require ssl for all requests");
|
||||||
loginSettingsPage.form().selectRequireSSL(RequireSSLOption.all);
|
loginSettingsPage.form().selectRequireSSL(RequireSSLOption.all);
|
||||||
loginSettingsPage.form().save();
|
loginSettingsPage.form().save();
|
||||||
|
assertAlertSuccess();
|
||||||
log.debug("set");
|
log.debug("set");
|
||||||
|
|
||||||
log.info("check HTTPS required");
|
log.info("check HTTPS required");
|
||||||
|
|
|
@ -19,28 +19,31 @@ package org.keycloak.testsuite.console.realm;
|
||||||
|
|
||||||
import org.jboss.arquillian.graphene.page.Page;
|
import org.jboss.arquillian.graphene.page.Page;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.keycloak.testsuite.auth.page.account.Account;
|
import org.keycloak.testsuite.auth.page.account.Account;
|
||||||
import org.keycloak.testsuite.console.page.realm.BruteForceDetection;
|
import org.keycloak.testsuite.console.page.realm.BruteForceDetection;
|
||||||
import org.keycloak.testsuite.console.page.users.UserAttributes;
|
import org.keycloak.testsuite.console.page.users.UserAttributes;
|
||||||
import org.keycloak.testsuite.console.page.users.Users;
|
import org.keycloak.testsuite.console.page.users.Users;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.WebElement;
|
||||||
|
import org.openqa.selenium.support.FindBy;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import static org.jboss.arquillian.graphene.Graphene.waitGui;
|
|
||||||
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD;
|
||||||
import static org.keycloak.testsuite.admin.Users.setPasswordFor;
|
import static org.keycloak.testsuite.admin.Users.setPasswordFor;
|
||||||
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
|
import static org.keycloak.testsuite.auth.page.AuthRealm.TEST;
|
||||||
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
||||||
|
import static org.keycloak.testsuite.util.WaitUtils.*;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Filip Kiss
|
* @author Filip Kiss
|
||||||
* @author mhajas
|
* @author mhajas
|
||||||
|
* @author Vaclav Muzikar <vmuzikar@redhat.com>
|
||||||
*/
|
*/
|
||||||
@Ignore
|
|
||||||
public class SecurityDefensesTest extends AbstractRealmTest {
|
public class SecurityDefensesTest extends AbstractRealmTest {
|
||||||
|
|
||||||
|
public static final String INVALID_PWD_MSG = "Invalid username or password.";
|
||||||
|
public static final String ACC_DISABLED_MSG = "Account is temporarily disabled, contact admin or try again later.";
|
||||||
|
public static final short ATTEMPTS_BAD_PWD = 2;
|
||||||
|
public static final short ATTEMPTS_GOOD_PWD = 1;
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
private BruteForceDetection bruteForceDetectionPage;
|
private BruteForceDetection bruteForceDetectionPage;
|
||||||
|
@ -54,6 +57,9 @@ public class SecurityDefensesTest extends AbstractRealmTest {
|
||||||
@Page
|
@Page
|
||||||
private UserAttributes userAttributesPage;
|
private UserAttributes userAttributesPage;
|
||||||
|
|
||||||
|
@FindBy(className = "kc-feedback-text")
|
||||||
|
private WebElement feedbackTextElement;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setDefaultPageUriParameters() {
|
public void setDefaultPageUriParameters() {
|
||||||
super.setDefaultPageUriParameters();
|
super.setDefaultPageUriParameters();
|
||||||
|
@ -66,157 +72,72 @@ public class SecurityDefensesTest extends AbstractRealmTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void maxLoginFailuresTest() {
|
public void maxLoginFailuresTest() throws InterruptedException {
|
||||||
int secondsToWait = 3;
|
final short secondsToWait = 3;
|
||||||
|
final short maxLoginFailures = 2;
|
||||||
|
|
||||||
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
||||||
bruteForceDetectionPage.form().setMaxLoginFailures("1");
|
bruteForceDetectionPage.form().setMaxLoginFailures(String.valueOf(maxLoginFailures));
|
||||||
bruteForceDetectionPage.form().setWaitIncrementSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
bruteForceDetectionPage.form().setWaitIncrementSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
bruteForceDetectionPage.form().setWaitIncrementInput(String.valueOf(secondsToWait));
|
bruteForceDetectionPage.form().setWaitIncrementInput(String.valueOf(secondsToWait));
|
||||||
|
bruteForceDetectionPage.form().setQuickLoginCheckInput("1");
|
||||||
bruteForceDetectionPage.form().save();
|
bruteForceDetectionPage.form().save();
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
tryToLogin(secondsToWait * (ATTEMPTS_BAD_PWD + ATTEMPTS_GOOD_PWD) / maxLoginFailures);
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD + "-mismatch");
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
waitForFeedbackText("Invalid username or password.");
|
|
||||||
Date endTime = new Date(new Date().getTime() + secondsToWait * 1000);
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
waitGui().until().element(By.className("instruction"))
|
|
||||||
.text().contains("Account is temporarily disabled, contact admin or try again later.");
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
testRealmAccountPage.navigateTo();
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
|
|
||||||
while (new Date().compareTo(endTime) < 0) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
assertCurrentUrlStartsWith(testRealmAccountPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void quickLoginCheck() {
|
public void quickLoginCheck() throws InterruptedException {
|
||||||
int secondsToWait = 3;
|
final short secondsToWait = 3;
|
||||||
|
|
||||||
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
||||||
bruteForceDetectionPage.form().setMaxLoginFailures("100");
|
bruteForceDetectionPage.form().setMaxLoginFailures("100");
|
||||||
bruteForceDetectionPage.form().setQuickLoginCheckInput("1500");
|
bruteForceDetectionPage.form().setQuickLoginCheckInput("10000");
|
||||||
bruteForceDetectionPage.form().setMinQuickLoginWaitSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
bruteForceDetectionPage.form().setMinQuickLoginWaitSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
bruteForceDetectionPage.form().setMinQuickLoginWaitInput(String.valueOf(secondsToWait));
|
bruteForceDetectionPage.form().setMinQuickLoginWaitInput(String.valueOf(secondsToWait));
|
||||||
bruteForceDetectionPage.form().save();
|
bruteForceDetectionPage.form().save();
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
tryToLogin(secondsToWait);
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD + "-mismatch");
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
Date endTime = new Date(new Date().getTime() + secondsToWait * 1000);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
waitGui().until().element(By.className("instruction"))
|
|
||||||
.text().contains("Account is temporarily disabled, contact admin or try again later.");
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
|
|
||||||
while (new Date().compareTo(endTime) < 0) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
assertCurrentUrlStartsWith(testRealmAccountPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void maxWaitLoginFailures() {
|
public void maxWaitLoginFailures() throws InterruptedException {
|
||||||
int secondsToWait = 5;
|
final short secondsToWait = 5;
|
||||||
|
|
||||||
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
||||||
bruteForceDetectionPage.form().setMaxLoginFailures("1");
|
bruteForceDetectionPage.form().setMaxLoginFailures("1");
|
||||||
|
bruteForceDetectionPage.form().setWaitIncrementSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
|
bruteForceDetectionPage.form().setWaitIncrementInput("10");
|
||||||
bruteForceDetectionPage.form().setMaxWaitSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
bruteForceDetectionPage.form().setMaxWaitSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
bruteForceDetectionPage.form().setMaxWaitInput(String.valueOf(secondsToWait));
|
bruteForceDetectionPage.form().setMaxWaitInput(String.valueOf(secondsToWait));
|
||||||
bruteForceDetectionPage.form().save();
|
bruteForceDetectionPage.form().save();
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
tryToLogin(secondsToWait);
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD + "-mismatch");
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
Date endTime = new Date(new Date().getTime() + secondsToWait * 1000);
|
|
||||||
waitForFeedbackText("Invalid username or password.");
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
waitGui().until().element(By.className("instruction"))
|
|
||||||
.text().contains("Account is temporarily disabled, contact admin or try again later.");
|
|
||||||
testRealmAccountPage.navigateTo();
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
endTime = new Date(endTime.getTime() + secondsToWait * 1000);
|
|
||||||
waitForFeedbackText("Account is temporarily disabled, contact admin or try again later.");
|
|
||||||
|
|
||||||
while (new Date().compareTo(endTime) < 0) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
assertCurrentUrlStartsWith(testRealmAccountPage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void failureResetTime() {
|
public void failureResetTime() throws InterruptedException {
|
||||||
int secondsToWait = 3;
|
final short failureResetTime = 3;
|
||||||
|
final short waitIncrement = 3;
|
||||||
|
|
||||||
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
bruteForceDetectionPage.form().setProtectionEnabled(true);
|
||||||
bruteForceDetectionPage.form().setMaxLoginFailures("2");
|
bruteForceDetectionPage.form().setMaxLoginFailures("1");
|
||||||
|
bruteForceDetectionPage.form().setWaitIncrementSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
|
bruteForceDetectionPage.form().setWaitIncrementInput(String.valueOf(waitIncrement));
|
||||||
bruteForceDetectionPage.form().setFailureResetTimeSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
bruteForceDetectionPage.form().setFailureResetTimeSelect(BruteForceDetection.TimeSelectValues.SECONDS);
|
||||||
bruteForceDetectionPage.form().setFailureResetTimeInput(String.valueOf(secondsToWait));
|
bruteForceDetectionPage.form().setFailureResetTimeInput(String.valueOf(failureResetTime));
|
||||||
bruteForceDetectionPage.form().save();
|
bruteForceDetectionPage.form().save();
|
||||||
assertAlertSuccess();
|
assertAlertSuccess();
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
tryToLogin(failureResetTime, false);
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD + "-mismatch");
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
testRealmLoginPage.form().login(testUser);
|
||||||
waitForFeedbackText("Invalid username or password.");
|
assertFeedbackText(ACC_DISABLED_MSG);
|
||||||
Date endTime = new Date(new Date().getTime() + secondsToWait * 1000);
|
|
||||||
|
|
||||||
while (new Date().compareTo(endTime) < 0) {
|
Thread.sleep(waitIncrement * 1000);
|
||||||
try {
|
|
||||||
Thread.sleep(50);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
|
||||||
waitForFeedbackText("Invalid username or password.");
|
|
||||||
|
|
||||||
setPasswordFor(testUser, PASSWORD);
|
|
||||||
testRealmLoginPage.form().login(testUser);
|
testRealmLoginPage.form().login(testUser);
|
||||||
assertCurrentUrlStartsWith(testRealmAccountPage);
|
assertCurrentUrlStartsWith(testRealmAccountPage);
|
||||||
}
|
}
|
||||||
|
@ -240,6 +161,7 @@ public class SecurityDefensesTest extends AbstractRealmTest {
|
||||||
|
|
||||||
usersPage.table().searchUsers(testUser.getUsername());
|
usersPage.table().searchUsers(testUser.getUsername());
|
||||||
usersPage.table().editUser(testUser.getUsername());
|
usersPage.table().editUser(testUser.getUsername());
|
||||||
|
assertFalse(userAttributesPage.form().isEnabled());
|
||||||
userAttributesPage.form().unlockUser();
|
userAttributesPage.form().unlockUser();
|
||||||
|
|
||||||
testRealmAccountPage.navigateTo();
|
testRealmAccountPage.navigateTo();
|
||||||
|
@ -250,8 +172,39 @@ public class SecurityDefensesTest extends AbstractRealmTest {
|
||||||
assertCurrentUrlStartsWith(testRealmAccountPage);
|
assertCurrentUrlStartsWith(testRealmAccountPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void waitForFeedbackText(String text) {
|
private void assertFeedbackText(String text) {
|
||||||
waitGui().until().element(By.className("kc-feedback-text"))
|
waitUntilElement(feedbackTextElement);
|
||||||
.text().contains(text);
|
assertEquals(text, feedbackTextElement.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryToLogin(int wait) throws InterruptedException {
|
||||||
|
tryToLogin(wait, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryToLogin(int wait, boolean finalLogin) throws InterruptedException {
|
||||||
|
testRealmAccountPage.navigateTo();
|
||||||
|
|
||||||
|
setPasswordFor(testUser, PASSWORD + "-mismatch");
|
||||||
|
|
||||||
|
for (int i = 0; i < ATTEMPTS_BAD_PWD; i++) {
|
||||||
|
testRealmLoginPage.form().login(testUser);
|
||||||
|
assertFeedbackText(INVALID_PWD_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
setPasswordFor(testUser, PASSWORD);
|
||||||
|
for (int i = 0; i < ATTEMPTS_GOOD_PWD; i++) {
|
||||||
|
testRealmLoginPage.form().login(testUser);
|
||||||
|
assertFeedbackText(ACC_DISABLED_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
wait *= 1000;
|
||||||
|
|
||||||
|
log.debug("Wait: " + wait);
|
||||||
|
Thread.sleep(wait);
|
||||||
|
|
||||||
|
if (finalLogin) {
|
||||||
|
testRealmLoginPage.form().login(testUser);
|
||||||
|
assertCurrentUrlStartsWith(testRealmAccountPage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ import static org.keycloak.testsuite.util.URLAssert.assertCurrentUrlStartsWith;
|
||||||
*
|
*
|
||||||
* @author Petr Mensik
|
* @author Petr Mensik
|
||||||
*/
|
*/
|
||||||
@Ignore
|
|
||||||
public class TokensTest extends AbstractRealmTest {
|
public class TokensTest extends AbstractRealmTest {
|
||||||
|
|
||||||
@Page
|
@Page
|
||||||
|
|
Loading…
Reference in a new issue