Browse Source

refactored credential menu exit

feature-vault
fdai6352 3 years ago
parent
commit
6b50608ef8
  1. 8
      src/main/java/Vault.java
  2. 2
      src/test/java/VaultTest.java

8
src/main/java/Vault.java

@ -124,6 +124,8 @@ public class Vault implements VaultInterface {
public void credentialMenu() { public void credentialMenu() {
StringBuilder sbcm = new StringBuilder(); StringBuilder sbcm = new StringBuilder();
Scanner scan = new Scanner(inputS);
credentialM = true;
sbcm.append("Configure credentials:\n"); sbcm.append("Configure credentials:\n");
sbcm.append("- add credential: a\n"); sbcm.append("- add credential: a\n");
@ -131,5 +133,11 @@ public class Vault implements VaultInterface {
sbcm.append("- exit: e\n"); sbcm.append("- exit: e\n");
println(sbcm.toString()); println(sbcm.toString());
String input = scan.nextLine();
if (input.equals("e")) {
credentialM = false;
}
} }
} }

2
src/test/java/VaultTest.java

@ -30,8 +30,10 @@ public class VaultTest {
@Test @Test
void openCredentialMenu() { void openCredentialMenu() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream; vlt.outputS = outputStream;
vlt.credentialMenu(); vlt.credentialMenu();
assertTrue(vlt.credentialM);
assertTrue(outputStream.toString().startsWith("Configure")); assertTrue(outputStream.toString().startsWith("Configure"));
} }

Loading…
Cancel
Save