|
|
@ -12,14 +12,23 @@ class PasswordValidatorTest { |
|
|
|
// test minimum password length |
|
|
|
passwordValidator.setMinLength(6); |
|
|
|
passwordValidator.setRequireUppercase(false); |
|
|
|
passwordValidator.setRequireLowercase(false); |
|
|
|
assertFalse(passwordValidator.validate("abcde")); |
|
|
|
assertTrue(passwordValidator.validate("abcdef")); |
|
|
|
assertTrue(passwordValidator.validate("abcdefg")); |
|
|
|
|
|
|
|
// test uppercase requirement |
|
|
|
passwordValidator.setRequireUppercase(true); |
|
|
|
passwordValidator.setRequireLowercase(false); |
|
|
|
assertFalse(passwordValidator.validate("abcdef")); |
|
|
|
assertTrue(passwordValidator.validate("abCdef")); |
|
|
|
assertTrue(passwordValidator.validate("ABCDEF")); |
|
|
|
|
|
|
|
// test lowercase requirement |
|
|
|
passwordValidator.setRequireUppercase(true); |
|
|
|
passwordValidator.setRequireLowercase(true); |
|
|
|
assertFalse(passwordValidator.validate("abcdef")); |
|
|
|
assertTrue(passwordValidator.validate("abCdef")); |
|
|
|
assertFalse(passwordValidator.validate("ABCDEF")); |
|
|
|
} |
|
|
|
} |