|
|
@ -90,38 +90,24 @@ public class VaultTest { |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
void openSetPWLength() { |
|
|
|
void openSetPWLengthMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("12".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.inputS = new ByteArrayInputStream("l\n7".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.setPWLength(); |
|
|
|
assertTrue(outputStream.toString().startsWith("Set")); |
|
|
|
vlt.configure(); |
|
|
|
assertEquals(7, vlt.PWLength); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setPWLength() { |
|
|
|
vlt.inputS = new ByteArrayInputStream("7\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.setPWLength(); |
|
|
|
vlt.setPWLength("7"); |
|
|
|
|
|
|
|
assertEquals(7, vlt.PWLength); |
|
|
|
assertTrue(outputStream.toString().contains("now:")); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setPWLengthWrongInput() { |
|
|
|
vlt.inputS = new ByteArrayInputStream("T\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.setPWLength(); |
|
|
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = getEmptyStringInputStream(); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
|
|
|
|
assertThrowsExactly(NoSuchElementException.class, () -> vlt.setPWLength()); |
|
|
|
assertTrue(outputStream.toString().startsWith("Set")); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setCapital() { |
|
|
|
vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|