|
|
@ -24,10 +24,10 @@ public class VaultTest { |
|
|
|
@BeforeEach |
|
|
|
void reset() { |
|
|
|
vlt.outputS = System.out; |
|
|
|
//vlt.inputS = System.in; |
|
|
|
vlt.inputS = getEmptyStringInputStream(); |
|
|
|
} |
|
|
|
|
|
|
|
/* @Test |
|
|
|
@Test |
|
|
|
void openCredentialMenu() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8)); |
|
|
@ -47,16 +47,20 @@ public class VaultTest { |
|
|
|
@Test |
|
|
|
void openAddCredentialMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("a".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.inputS = new ByteArrayInputStream("a\npeter\npassword".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.credentialMenu(); |
|
|
|
assertTrue(outputStream.toString().contains("Type")); |
|
|
|
|
|
|
|
assertTrue(outputStream.toString().contains("username")); |
|
|
|
assertEquals("peter", vlt.userName); |
|
|
|
assertTrue(outputStream.toString().contains("password")); |
|
|
|
assertEquals("password",vlt.password); |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void openShowCredentialMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("c".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.inputS = new ByteArrayInputStream("c\n1".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.credentialMenu(); |
|
|
|
assertTrue(outputStream.toString().contains("Type")); |
|
|
@ -65,13 +69,21 @@ 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 |
|
|
|
/*@Test |
|
|
|
void editCredentialTest() { |
|
|
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
/*@Test |
|
|
|
void addCredentialTest() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.outputS = outputStream; |
|
|
@ -86,19 +98,14 @@ public class VaultTest { |
|
|
|
|
|
|
|
@Test |
|
|
|
void showCredentialTest() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.inputS = new ByteArrayInputStream("1".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.showCredential(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("l\n1".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.credentialMenu(); |
|
|
|
|
|
|
|
assertTrue(outputStream.toString().contains("Type")); |
|
|
|
assertTrue(vlt.isInt); |
|
|
|
|
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.inputS = new ByteArrayInputStream("peter".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.showCredential(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("l\npeter".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.credentialMenu(); |
|
|
|
|
|
|
|
assertTrue(outputStream.toString().contains("Type")); |
|
|
|
assertFalse(vlt.isInt); |
|
|
|
}*/ |
|
|
|
|
|
|
@ -108,7 +115,7 @@ public class VaultTest { |
|
|
|
@Test |
|
|
|
void loadFromJson() {vlt.loadFromJson();} |
|
|
|
|
|
|
|
/* @Test |
|
|
|
@Test |
|
|
|
void openConfigureMenu() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8)); |
|
|
@ -122,9 +129,9 @@ public class VaultTest { |
|
|
|
vlt.inputS = new ByteArrayInputStream("e".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.configure(); |
|
|
|
assertFalse(vlt.config); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
/* @Test |
|
|
|
@Test |
|
|
|
void doNotExitConfigAfterWrongInput() { |
|
|
|
vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.configure(); |
|
|
@ -136,9 +143,9 @@ public class VaultTest { |
|
|
|
|
|
|
|
assertThrowsExactly(NoSuchElementException.class, () -> vlt.configure()); |
|
|
|
assertTrue(outputStream.toString().startsWith("Configure:")); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
/* @Test |
|
|
|
@Test |
|
|
|
void openSetPWLengthMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("l\n7".getBytes(StandardCharsets.UTF_8)); |
|
|
@ -146,7 +153,7 @@ public class VaultTest { |
|
|
|
vlt.configure(); |
|
|
|
assertEquals(7, vlt.PWLength); |
|
|
|
assertTrue(outputStream.toString().contains("Set")); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setPWLength() { |
|
|
@ -158,14 +165,14 @@ public class VaultTest { |
|
|
|
assertTrue(outputStream.toString().contains("now:")); |
|
|
|
} |
|
|
|
|
|
|
|
/*@Test |
|
|
|
@Test |
|
|
|
void openSetCapitalsMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.configure(); |
|
|
|
assertTrue(vlt.haveCapitals = true); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setCapitals() { |
|
|
@ -181,17 +188,16 @@ public class VaultTest { |
|
|
|
|
|
|
|
assertFalse(vlt.haveCapitals = false); |
|
|
|
assertTrue(outputStream.toString().contains("don't")); |
|
|
|
System.out.println(outputStream.toString()); |
|
|
|
} |
|
|
|
|
|
|
|
/*@Test |
|
|
|
@Test |
|
|
|
void openSetSpecialCharsMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.configure(); |
|
|
|
assertTrue(vlt.hasSpecialChars = true); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setSpecialCharTest() { |
|
|
@ -208,14 +214,14 @@ public class VaultTest { |
|
|
|
assertTrue(outputStream.toString().contains("don't")); |
|
|
|
} |
|
|
|
|
|
|
|
/*@Test |
|
|
|
@Test |
|
|
|
void openSetNumbersMenuItem() { |
|
|
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); |
|
|
|
vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); |
|
|
|
vlt.outputS = outputStream; |
|
|
|
vlt.configure(); |
|
|
|
assertTrue(vlt.hasNumbers = true); |
|
|
|
}*/ |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
void setNumbersTest() { |
|
|
|