|
@ -28,7 +28,17 @@ public class VaultTest { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void addCredential() {vlt.addCredential();} |
|
|
|
|
|
|
|
|
void addCredentialTest() { |
|
|
|
|
|
String expected = "user"; |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream(expected.getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
|
|
|
vlt.addCredential(); |
|
|
|
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Add")); |
|
|
|
|
|
assertEquals(expected, vlt.userName); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void showCredential() {vlt.showCredential();} |
|
|
void showCredential() {vlt.showCredential();} |
|
@ -70,94 +80,95 @@ public class VaultTest { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void openSetPWLength() { |
|
|
|
|
|
|
|
|
void openSetPWLengthMenuItem() { |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
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.outputS = outputStream; |
|
|
vlt.setPWLength(); |
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Set")); |
|
|
|
|
|
|
|
|
vlt.configure(); |
|
|
|
|
|
assertEquals(7, vlt.PWLength); |
|
|
|
|
|
assertTrue(outputStream.toString().contains("Set")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void setPWLength() { |
|
|
void setPWLength() { |
|
|
vlt.inputS = new ByteArrayInputStream("7\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.setPWLength(); |
|
|
|
|
|
|
|
|
vlt.setPWLength("7"); |
|
|
|
|
|
|
|
|
assertEquals(7, vlt.PWLength); |
|
|
assertEquals(7, vlt.PWLength); |
|
|
assertTrue(outputStream.toString().contains("now:")); |
|
|
assertTrue(outputStream.toString().contains("now:")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void setPWLengthWrongInput() { |
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("T\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.setPWLength(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void openSetCapitalsMenuItem() { |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
vlt.inputS = getEmptyStringInputStream(); |
|
|
|
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
|
|
|
|
|
|
assertThrowsExactly(NoSuchElementException.class, () -> vlt.setPWLength()); |
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Set")); |
|
|
|
|
|
|
|
|
vlt.configure(); |
|
|
|
|
|
assertTrue(vlt.haveCapitals = true); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void setCapital() { |
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
|
|
|
void setCapitals() { |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.setCapital(); |
|
|
|
|
|
|
|
|
vlt.setCapital("yes"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertTrue(vlt.haveCapitals = true); |
|
|
assertTrue(vlt.haveCapitals = true); |
|
|
assertTrue(outputStream.toString().contains("contain")); |
|
|
assertTrue(outputStream.toString().contains("contain")); |
|
|
|
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.setCapital(); |
|
|
|
|
|
|
|
|
vlt.setCapital("no"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertFalse(vlt.haveCapitals = false); |
|
|
assertFalse(vlt.haveCapitals = false); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void openSetSpecialCharsMenuItem() { |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
|
|
|
vlt.configure(); |
|
|
|
|
|
assertTrue(vlt.hasSpecialChars = true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void setSpecialCharTest() { |
|
|
void setSpecialCharTest() { |
|
|
vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.setSpecialChar(); |
|
|
|
|
|
|
|
|
vlt.setSpecialChar("yes"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertTrue(vlt.hasSpecialChars = true); |
|
|
assertTrue(vlt.hasSpecialChars = true); |
|
|
assertTrue(outputStream.toString().contains("contain")); |
|
|
|
|
|
|
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.setSpecialChar(); |
|
|
|
|
|
|
|
|
vlt.setSpecialChar("no"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertFalse(vlt.hasSpecialChars = false); |
|
|
assertFalse(vlt.hasSpecialChars = false); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void openSetNumbersMenuItem() { |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
|
|
|
vlt.configure(); |
|
|
|
|
|
assertTrue(vlt.hasNumbers = true); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
|
void setNumbersTest() { |
|
|
void setNumbersTest() { |
|
|
vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.SetNumbers(); |
|
|
|
|
|
|
|
|
vlt.setNumbers("yes"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertTrue(vlt.hasNumbers = true); |
|
|
assertTrue(vlt.hasNumbers = true); |
|
|
assertTrue(outputStream.toString().contains("contain")); |
|
|
assertTrue(outputStream.toString().contains("contain")); |
|
|
|
|
|
|
|
|
vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
vlt.outputS = outputStream; |
|
|
vlt.SetNumbers(); |
|
|
|
|
|
|
|
|
vlt.setNumbers("no"); |
|
|
|
|
|
|
|
|
assertTrue(outputStream.toString().startsWith("Should")); |
|
|
|
|
|
assertFalse(vlt.hasNumbers = false); |
|
|
assertFalse(vlt.hasNumbers = false); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
assertTrue(outputStream.toString().contains("don´t")); |
|
|
} |
|
|
} |
|
|