diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index b66b615..e504a64 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -14,6 +14,7 @@ public class Vault implements VaultInterface { public boolean credentialM; public String userName; public String password; + public boolean isInt = false; InputStream inputS = System.in; OutputStream outputS = System.out; @@ -85,6 +86,15 @@ public class Vault implements VaultInterface { } public void showCredential(){ + Scanner scan = new Scanner(inputS); + println("Type in ID or username"); + + String str = scan.nextLine(); + + if(str.matches("[0-9]+")) { + isInt = true; + //getCredentialsViaId(Integer.parseInt(str)); + } } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 3a820a5..0116dc1 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -85,7 +85,15 @@ public class VaultTest { } @Test - void showCredential() {vlt.showCredential();} + void showCredentialTest() { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.outputS = outputStream; + vlt.inputS = new ByteArrayInputStream("1".getBytes(StandardCharsets.UTF_8)); + vlt.showCredential(); + + assertTrue(outputStream.toString().contains("Type")); + assertTrue(vlt.isInt); + } @Test void getAsJson() {vlt.getAsJson();}