7 Commits

  1. 30
      src/main/java/Vault.java
  2. 44
      src/test/java/VaultTest.java

30
src/main/java/Vault.java

@ -11,7 +11,7 @@ public class Vault implements VaultInterface {
public boolean haveCapitals;
public boolean hasSpecialChars;
public boolean hasNumbers;
public String userName;
public boolean credentialM;
InputStream inputS = System.in;
OutputStream outputS = System.out;
@ -56,7 +56,7 @@ public class Vault implements VaultInterface {
} else if (input.equals("n")) {
println("Should you PW have numbers? Type in yes or no.");
String inputN = scan.nextLine();
setNumbers(input);
setNumbers(inputN);
}
}
@ -120,4 +120,30 @@ public class Vault implements VaultInterface {
println("Your PWs don´t have numbers anymore.");
}
}
public void credentialMenu() {
StringBuilder sbcm = new StringBuilder();
Scanner scan = new Scanner(inputS);
credentialM = true;
sbcm.append("Configure credentials:\n");
sbcm.append("- add credential: a\n");
sbcm.append("- show credential: c\n");
sbcm.append("- edit credential: l\n");
sbcm.append("- exit: e\n");
println(sbcm.toString());
String input = scan.nextLine();
if (input.equals("e")) {
credentialM = false;
} else if (input.equals("a")) {
println("Type username:");
} else if (input.equals("c")) {
println("Type username or ID to show credential:");
} else if (input.equals("l")) {
println("Type username or ID to select credential:");
}
}
}

44
src/test/java/VaultTest.java

@ -27,6 +27,50 @@ public class VaultTest {
vlt.inputS = System.in;
}
@Test
void openCredentialMenu() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.credentialMenu();
assertTrue(vlt.credentialM);
assertTrue(outputStream.toString().startsWith("Configure"));
}
@Test
void exitConfigureMenu(){
vlt.inputS = new ByteArrayInputStream("e".getBytes(StandardCharsets.UTF_8));
vlt.credentialMenu();
assertFalse(vlt.credentialM);
}
@Test
void openAddCredentialMenuItem() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("a".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.credentialMenu();
assertTrue(outputStream.toString().contains("Type"));
}
@Test
void openShowCredentialMenuItem() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("c".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.credentialMenu();
assertTrue(outputStream.toString().contains("Type"));
}
@Test
void openEditCredentialMenuItem() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("l".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.credentialMenu();
assertTrue(outputStream.toString().contains("Type"));
}
@Test
void addCredentialTest() { vlt.addCredential();}

Loading…
Cancel
Save