|
|
@ -15,16 +15,17 @@ class PasswordGeneratorTest { |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void generateRandomPassword() { |
|
|
|
void testGeneratedPasswordLength() { |
|
|
|
assertNotSame("", passwordGenerator.generateRandomPassword()); |
|
|
|
assertEquals(passwordGenerator.generateRandomPassword().length(), passwordGenerator.getLength()); |
|
|
|
|
|
|
|
// test length requirement |
|
|
|
passwordGenerator.setLength(33); |
|
|
|
assertEquals(passwordGenerator.getLength(), 33); |
|
|
|
assertEquals(passwordGenerator.generateRandomPassword().length(), passwordGenerator.getLength()); |
|
|
|
} |
|
|
|
|
|
|
|
// test lowercase requirement |
|
|
|
@Test |
|
|
|
void testPasswordLowercaseRequirement() { |
|
|
|
assertTrue(Pattern.compile("^(?=.*[a-z]).+$").matcher(passwordGenerator.generateRandomPassword()).matches()); |
|
|
|
} |
|
|
|
} |