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