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