|
@ -13,6 +13,7 @@ class PasswordValidatorTest { |
|
|
passwordValidator.setMinLength(6); |
|
|
passwordValidator.setMinLength(6); |
|
|
passwordValidator.setRequireUppercase(false); |
|
|
passwordValidator.setRequireUppercase(false); |
|
|
passwordValidator.setRequireLowercase(false); |
|
|
passwordValidator.setRequireLowercase(false); |
|
|
|
|
|
passwordValidator.setRequireDigit(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")); |
|
@ -20,6 +21,7 @@ class PasswordValidatorTest { |
|
|
// test uppercase requirement |
|
|
// test uppercase requirement |
|
|
passwordValidator.setRequireUppercase(true); |
|
|
passwordValidator.setRequireUppercase(true); |
|
|
passwordValidator.setRequireLowercase(false); |
|
|
passwordValidator.setRequireLowercase(false); |
|
|
|
|
|
passwordValidator.setRequireDigit(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")); |
|
@ -27,8 +29,22 @@ class PasswordValidatorTest { |
|
|
// test lowercase requirement |
|
|
// test lowercase requirement |
|
|
passwordValidator.setRequireUppercase(true); |
|
|
passwordValidator.setRequireUppercase(true); |
|
|
passwordValidator.setRequireLowercase(true); |
|
|
passwordValidator.setRequireLowercase(true); |
|
|
|
|
|
passwordValidator.setRequireDigit(false); |
|
|
assertFalse(passwordValidator.validate("abcdef")); |
|
|
assertFalse(passwordValidator.validate("abcdef")); |
|
|
assertTrue(passwordValidator.validate("abCdef")); |
|
|
assertTrue(passwordValidator.validate("abCdef")); |
|
|
assertFalse(passwordValidator.validate("ABCDEF")); |
|
|
assertFalse(passwordValidator.validate("ABCDEF")); |
|
|
|
|
|
|
|
|
|
|
|
// test digits requirement |
|
|
|
|
|
passwordValidator.setRequireUppercase(true); |
|
|
|
|
|
passwordValidator.setRequireLowercase(true); |
|
|
|
|
|
passwordValidator.setRequireDigit(true); |
|
|
|
|
|
assertFalse(passwordValidator.validate("8")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("12345678")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("abcdef")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("abcdef8")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("abCdef")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("ABCDEF")); |
|
|
|
|
|
assertFalse(passwordValidator.validate("ABCDEF8")); |
|
|
|
|
|
assertTrue(passwordValidator.validate("abCDE8F")); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |