Merge pull request #1746 from mhajas/master
KEYCLOAK-1865 - Stabilize some integration-arquillian tests
This commit is contained in:
commit
f99395aebe
4 changed files with 53 additions and 31 deletions
|
@ -82,10 +82,10 @@ public class PasswordPolicy extends Authentication {
|
|||
|
||||
public enum Type {
|
||||
|
||||
HASH_ITERATIONS("Hash Iterations"), LENGTH("Length"), DIGITS("Digits"), LOWER_CASE("Lower Case"),
|
||||
UPPER_CASE("Upper Case"), SPECIAL_CHARS("Special Chars"), NOT_USERNAME("Not Username"),
|
||||
REGEX_PATTERN("Regex Pattern"), PASSWORD_HISTORY("Password History"),
|
||||
FORCE_EXPIRED_PASSWORD_CHANGE("Force Expired Password Change");
|
||||
HASH_ITERATIONS("HashIterations"), LENGTH("Length"), DIGITS("Digits"), LOWER_CASE("LowerCase"),
|
||||
UPPER_CASE("UpperCase"), SPECIAL_CHARS("SpecialChars"), NOT_USERNAME("NotUsername"),
|
||||
REGEX_PATTERN("RegexPattern"), PASSWORD_HISTORY("PasswordHistory"),
|
||||
FORCE_EXPIRED_PASSWORD_CHANGE("ForceExpiredPasswordChange");
|
||||
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -19,19 +19,19 @@ package org.keycloak.testsuite.console.authentication;
|
|||
|
||||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.testsuite.console.AbstractConsoleTest;
|
||||
import org.keycloak.testsuite.console.page.authentication.PasswordPolicy;
|
||||
import org.keycloak.testsuite.console.page.users.UserCredentials;
|
||||
|
||||
import static org.keycloak.testsuite.console.page.authentication.PasswordPolicy.Type.*;
|
||||
import static org.keycloak.testsuite.console.page.authentication.PasswordPolicy.Type.HASH_ITERATIONS;
|
||||
import static org.keycloak.testsuite.console.page.authentication.PasswordPolicy.Type.REGEX_PATTERN;
|
||||
|
||||
/**
|
||||
* @author Petr Mensik
|
||||
* @author mhajas
|
||||
*/
|
||||
@Ignore // FIXME still unstable
|
||||
public class PasswordPolicyTest extends AbstractConsoleTest {
|
||||
|
||||
@Page
|
||||
|
@ -43,11 +43,11 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
@Before
|
||||
public void beforePasswordPolicyTest() {
|
||||
testUserCredentialsPage.setId(testUser.getId());
|
||||
passwordPolicyPage.navigateTo();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAddAndRemovePolicy() {
|
||||
passwordPolicyPage.navigateTo();
|
||||
passwordPolicyPage.addPolicy(HASH_ITERATIONS, 5);
|
||||
passwordPolicyPage.removePolicy(HASH_ITERATIONS);
|
||||
assertFlashMessageSuccess();
|
||||
|
@ -55,17 +55,20 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testInvalidPolicyValues() {
|
||||
passwordPolicyPage.navigateTo();
|
||||
passwordPolicyPage.addPolicy(HASH_ITERATIONS, "asd");
|
||||
assertFlashMessageDanger();
|
||||
passwordPolicyPage.removePolicy(HASH_ITERATIONS);
|
||||
|
||||
passwordPolicyPage.addPolicy(REGEX_PATTERN, "^[A-Z]{8,5}");
|
||||
passwordPolicyPage.addPolicy(REGEX_PATTERN, "([");
|
||||
assertFlashMessageDanger();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLengthPolicy() {
|
||||
passwordPolicyPage.addPolicy(LENGTH, 8);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("length(8) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("1234567");
|
||||
|
@ -77,7 +80,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testDigitsPolicy() {
|
||||
passwordPolicyPage.addPolicy(DIGITS, 2);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("digits(2) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("invalidPassword1");
|
||||
|
@ -89,7 +94,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testLowerCasePolicy() {
|
||||
passwordPolicyPage.addPolicy(LOWER_CASE, 2);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("lowerCase(2) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("iNVALIDPASSWORD");
|
||||
|
@ -101,7 +108,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testUpperCasePolicy() {
|
||||
passwordPolicyPage.addPolicy(UPPER_CASE, 2);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("upperCase(2) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("Invalidpassword");
|
||||
|
@ -113,7 +122,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testSpecialCharsPolicy() {
|
||||
passwordPolicyPage.addPolicy(SPECIAL_CHARS, 2);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("specialChars(2) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("invalidPassword*");
|
||||
|
@ -125,7 +136,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testNotUsernamePolicy() {
|
||||
passwordPolicyPage.addPolicy(NOT_USERNAME);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("notUsername(1) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword(testUser.getUsername());
|
||||
|
@ -137,7 +150,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testRegexPatternsPolicy() {
|
||||
passwordPolicyPage.addPolicy(REGEX_PATTERN, "^[A-Z]+#[a-z]{8}$");
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("regexPattern(^[A-Z]+#[a-z]{8}$) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("invalidPassword");
|
||||
|
@ -149,7 +164,9 @@ public class PasswordPolicyTest extends AbstractConsoleTest {
|
|||
|
||||
@Test
|
||||
public void testPasswordHistoryPolicy() {
|
||||
passwordPolicyPage.addPolicy(PASSWORD_HISTORY, 2);
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
realm.setPasswordPolicy("passwordHistory(2) and ");
|
||||
testRealmResource().update(realm);
|
||||
|
||||
testUserCredentialsPage.navigateTo();
|
||||
testUserCredentialsPage.resetPassword("firstPassword");
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.jboss.arquillian.graphene.page.Page;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.representations.idm.ClientRepresentation;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.testsuite.admin.ApiUtil;
|
||||
import org.keycloak.testsuite.console.AbstractConsoleTest;
|
||||
import org.keycloak.testsuite.console.clients.AbstractClientTest;
|
||||
|
@ -13,11 +14,11 @@ import org.keycloak.testsuite.console.page.events.Config;
|
|||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
/**
|
||||
* @author mhajas
|
||||
|
@ -37,10 +38,12 @@ public class AdminEventsTest extends AbstractConsoleTest {
|
|||
|
||||
@Before
|
||||
public void beforeAdminEventsTest() {
|
||||
configPage.navigateTo();
|
||||
configPage.form().setSaveAdminEvents(true);
|
||||
configPage.form().setIncludeRepresentation(true);
|
||||
configPage.form().save();
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
|
||||
realm.setAdminEventsEnabled(true);
|
||||
realm.setAdminEventsDetailsEnabled(true);
|
||||
|
||||
testRealmResource().update(realm);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -3,6 +3,7 @@ package org.keycloak.testsuite.console.events;
|
|||
import org.jboss.arquillian.graphene.page.Page;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.keycloak.representations.idm.RealmRepresentation;
|
||||
import org.keycloak.testsuite.admin.Users;
|
||||
import org.keycloak.testsuite.console.AbstractConsoleTest;
|
||||
import org.keycloak.testsuite.console.page.events.Config;
|
||||
|
@ -10,6 +11,7 @@ import org.keycloak.testsuite.console.page.events.LoginEvents;
|
|||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebElement;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -21,18 +23,18 @@ import static org.keycloak.representations.idm.CredentialRepresentation.PASSWORD
|
|||
public class LoginEventsTest extends AbstractConsoleTest {
|
||||
@Page
|
||||
private LoginEvents loginEventsPage;
|
||||
|
||||
@Page
|
||||
private Config configPage;
|
||||
|
||||
|
||||
@Before
|
||||
public void beforeLoginEventsTest() {
|
||||
configPage.navigateTo();
|
||||
configPage.form().setSaveEvents(true);
|
||||
configPage.form().waitForClearEventsButtonPresent();
|
||||
configPage.form().addSaveType("LOGIN");
|
||||
configPage.form().addSaveType("LOGIN_ERROR");
|
||||
configPage.form().addSaveType("LOGOUT");
|
||||
configPage.form().save();
|
||||
RealmRepresentation realm = testRealmResource().toRepresentation();
|
||||
|
||||
realm.setEventsEnabled(true);
|
||||
realm.setEnabledEventTypes(Arrays.asList("LOGIN", "LOGIN_ERROR", "LOGOUT"));
|
||||
|
||||
testRealmResource().update(realm);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue