Browse Source

implemented userName for new credentials

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

8
src/main/java/Vault.java

@ -11,6 +11,7 @@ public class Vault implements VaultInterface {
public boolean haveCapitals; public boolean haveCapitals;
public boolean hasSpecialChars; public boolean hasSpecialChars;
public boolean hasNumbers; public boolean hasNumbers;
public String userName;
InputStream inputS = System.in; InputStream inputS = System.in;
OutputStream outputS = System.out; OutputStream outputS = System.out;
@ -61,6 +62,13 @@ public class Vault implements VaultInterface {
public void addCredential(){ public void addCredential(){
println("Add user name");
Scanner scan = new Scanner(inputS);
String input = scan.nextLine();
userName = input;
} }

12
src/test/java/VaultTest.java

@ -28,7 +28,17 @@ public class VaultTest {
} }
@Test @Test
void addCredential() {vlt.addCredential();}
void addCredentialTest() {
String expected = "user";
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.inputS = new ByteArrayInputStream(expected.getBytes(StandardCharsets.UTF_8));
vlt.outputS = outputStream;
vlt.addCredential();
assertTrue(outputStream.toString().startsWith("Add"));
assertEquals(expected, vlt.userName);
}
@Test @Test
void showCredential() {vlt.showCredential();} void showCredential() {vlt.showCredential();}

Loading…
Cancel
Save