Browse Source

Merge commit '0493a8a13d3e725d5cec4f3dc244f5fe7ca2c9a4' into HEAD

development
jenkins 3 years ago
parent
commit
bb8f532111
  1. 15
      src/main/java/Vault.java
  2. 11
      src/test/java/VaultTest.java

15
src/main/java/Vault.java

@ -21,6 +21,7 @@ public class Vault implements VaultInterface {
OutputStream outputS = System.out;
private CredentialRepository credentialRepository = new CredentialRepository();
private PasswordGenerator passwordGenerator = new PasswordGenerator();
/*public static void main (String args[]) {
Vault vault = new Vault();
@ -99,9 +100,17 @@ public class Vault implements VaultInterface {
println("Type in username");
userName = scan.nextLine();
println("Type in password");
password = scan.nextLine();
credentialRepository.createNewCredential(userName, password);
println("Do you want to set your password manually?\nyes or no");
if(scan.nextLine().equals("yes")) {
println("Type in password");
password = scan.nextLine();
credentialRepository.createNewCredential(userName, password);
} else {
println("Generating password.");
password = passwordGenerator.generateRandomPassword();
credentialRepository.createNewCredential(userName, password);
}
}
public void showCredential() {

11
src/test/java/VaultTest.java

@ -64,13 +64,22 @@ public class VaultTest {
void addCredentialTest() {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
vlt.outputS = outputStream;
vlt.inputS = new ByteArrayInputStream("peter\npassword".getBytes(StandardCharsets.UTF_8));
vlt.inputS = new ByteArrayInputStream("peter\nyes\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);
vlt.inputS = new ByteArrayInputStream("peter\nno".getBytes(StandardCharsets.UTF_8));
vlt.addCredential();
assertTrue(outputStream.toString().contains("username"));
assertEquals("peter", vlt.userName);
assertTrue(outputStream.toString().contains("password"));
assertNotEquals(0, vlt.password.length());
}
@Test

Loading…
Cancel
Save