Browse Source

implemented add credential functionality

feature-vault
fdai6352 3 years ago
parent
commit
f89a4e4af1
  1. 9
      src/main/java/Vault.java
  2. 12
      src/test/java/VaultTest.java

9
src/main/java/Vault.java

@ -12,6 +12,8 @@ public class Vault implements VaultInterface {
public boolean hasSpecialChars; public boolean hasSpecialChars;
public boolean hasNumbers; public boolean hasNumbers;
public boolean credentialM; public boolean credentialM;
public String userName;
public String password;
InputStream inputS = System.in; InputStream inputS = System.in;
OutputStream outputS = System.out; OutputStream outputS = System.out;
@ -72,6 +74,13 @@ public class Vault implements VaultInterface {
public void addCredential(){ public void addCredential(){
Scanner scan = new Scanner(inputS);
println("Type in username");
userName = scan.nextLine();
println("Type in password");
password = scan.nextLine();
//createNewCredential(userName, password);
} }

12
src/test/java/VaultTest.java

@ -72,7 +72,17 @@ public class VaultTest {
} }
@Test @Test
void addCredentialTest() { vlt.addCredential();}
void addCredentialTest() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.outputS = outputStream;
vlt.inputS = new ByteArrayInputStream("peter\npassword".getBytes(StandardCharsets.UTF_8));
vlt.addCredential();
assertTrue(outputStream.toString().contains("username"));
assertEquals("peter", vlt.userName);
assertTrue(outputStream.toString().contains("password"));
assertEquals("password",vlt.password);
}
@Test @Test
void showCredential() {vlt.showCredential();} void showCredential() {vlt.showCredential();}

Loading…
Cancel
Save