Browse Source

implemented show credential via ID functionality

feature-vault
fdai6352 3 years ago
parent
commit
044d4af707
  1. 10
      src/main/java/Vault.java
  2. 10
      src/test/java/VaultTest.java

10
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));
}
}

10
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();}

Loading…
Cancel
Save