Merge pull request #1861 from stianst/KEYCLOAK-1971

KEYCLOAK-1971 REST end point does't validate password policies properly
This commit is contained in:
Stian Thorgersen 2015-11-24 21:55:16 +01:00
commit 94ba87ac05
2 changed files with 11 additions and 0 deletions

View file

@ -76,6 +76,8 @@ public class PasswordPolicy implements Serializable {
list.add(new PasswordHistory(arg));
} else if (name.equals(ForceExpiredPasswordChange.NAME)) {
list.add(new ForceExpiredPasswordChange(arg));
} else {
throw new IllegalArgumentException("Unsupported policy");
}
}
return list;

View file

@ -83,6 +83,15 @@ public class PasswordPolicyTest {
Assert.assertEquals("invalidPasswordNotUsernameMessage", policy.validate("jdoe", "jdoe").getMessage());
Assert.assertNull(policy.validate("jdoe", "ab&d1234"));
}
@Test
public void testInvalidPolicyName() {
try {
PasswordPolicy policy = new PasswordPolicy("noSuchPolicy");
Assert.fail("Expected exception");
} catch (IllegalArgumentException e) {
}
}
@Test
public void testRegexPatterns() {