Browse Source

refactored edit credential menu and test

feature-credential
fdai6352 3 years ago
parent
commit
92d763d836
  1. 18
      src/main/java/Vault.java
  2. 10
      src/test/java/VaultTest.java

18
src/main/java/Vault.java

@ -14,6 +14,9 @@ public class Vault implements VaultInterface {
public boolean credentialM;
public String userName;
public String password;
public int newID;
public String newString;
public boolean decision;
InputStream inputS = System.in;
OutputStream outputS = System.out;
private CredentialRepository credentialRepository = new CredentialRepository();
@ -96,6 +99,7 @@ public class Vault implements VaultInterface {
}
}
public void getAsJson(){
}
@ -174,7 +178,19 @@ public class Vault implements VaultInterface {
showCredential(str);
} else if (input.equals("l")) {
println("Type username or ID to select credential:");
println("Type ID to select credential:");
newID = Integer.parseInt(scan.nextLine());
println("-change username: u\n-change password: p");
input = scan.nextLine();
if (input.equals("u")) {
decision = true;
}else{
decision = false;
}
println("Type new:");
newString = scan.nextLine();
//editCredential(newID, newString, decision);
}
}
}

10
src/test/java/VaultTest.java

@ -69,12 +69,20 @@ public class VaultTest {
@Test
void openEditCredentialMenuItem() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream("l".getBytes(StandardCharsets.UTF_8));
vlt.inputS = new ByteArrayInputStream("l\n1\nu\npeter".getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.credentialMenu();
assertTrue(outputStream.toString().contains("Type"));
assertEquals(1,vlt.newID);
assertEquals(true,vlt.decision);
assertEquals("peter",vlt.newString);
}
/*@Test
void editCredentialTest() {
}*/
/*@Test
void addCredentialTest() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

Loading…
Cancel
Save