From dfffc3c84a6e0fd5a78e8a2076df8d47e2be28b8 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 00:42:09 +0100 Subject: [PATCH 01/12] added set special characters function and VaultInterface refactor --- src/main/java/Vault.java | 21 +++++++++++++++++++-- src/main/java/VaultInterface.java | 11 +++++------ src/test/java/VaultTest.java | 20 ++++++++++++++++++++ 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 4405ee1..225eea0 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -8,7 +8,8 @@ public class Vault implements VaultInterface { public boolean config; public int PWLength; - public boolean haveCapitals = false; + public boolean haveCapitals; + public boolean hasSpecialChars; InputStream inputS = System.in; OutputStream outputS = System.out; @@ -75,7 +76,7 @@ public class Vault implements VaultInterface { } public void setCapital() { - println("Should you PW have Capitals? Type in yes or no."); + println("Should you PW have capitals? Type in yes or no."); Scanner scan = new Scanner(inputS); String input = scan.nextLine(); @@ -88,4 +89,20 @@ public class Vault implements VaultInterface { println("Your PWs don´t have capitals anymore."); } } + + + public void setSpecialChar() { + println("Should you PW have special characters? Type in yes or no."); + + Scanner scan = new Scanner(inputS); + String input = scan.nextLine(); + + if(input.equals("yes")){ + hasSpecialChars = true; + println("Your PWs contain now special characters."); + }else if(input.equals("no")){ + hasSpecialChars = false; + println("Your PWs don´t have special characters anymore."); + } + } } diff --git a/src/main/java/VaultInterface.java b/src/main/java/VaultInterface.java index 50bbd1d..9f1fc26 100644 --- a/src/main/java/VaultInterface.java +++ b/src/main/java/VaultInterface.java @@ -2,10 +2,9 @@ public interface VaultInterface { - public void configure(); - public void addCredential(); - public void showCredential(); - public void getAsJson(); - public void loadFromJson(); - + void configure(); + void addCredential(); + void showCredential(); + void getAsJson(); + void loadFromJson(); } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index dcb0668..8aedbc3 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -122,6 +122,26 @@ public class VaultTest { assertTrue(outputStream.toString().contains("don´t")); } + @Test + void setSpecialCharTest() { + vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.outputS = outputStream; + vlt.setSpecialChar(); + + assertTrue(outputStream.toString().startsWith("Should")); + assertTrue(vlt.hasSpecialChars = true); + assertTrue(outputStream.toString().contains("contain")); + + vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); + vlt.outputS = outputStream; + vlt.setSpecialChar(); + + assertTrue(outputStream.toString().startsWith("Should")); + assertFalse(vlt.hasSpecialChars = false); + assertTrue(outputStream.toString().contains("don´t")); + } + private ByteArrayInputStream getEmptyStringInputStream() { return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8)); } From db0423a18ccb7de0d7bef52be8563da306e1200a Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 00:44:59 +0100 Subject: [PATCH 02/12] added set numbers function --- src/main/java/Vault.java | 16 ++++++++++++++++ src/test/java/VaultTest.java | 20 ++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 225eea0..6b833c3 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -10,6 +10,7 @@ public class Vault implements VaultInterface { public int PWLength; public boolean haveCapitals; public boolean hasSpecialChars; + public boolean hasNumbers; InputStream inputS = System.in; OutputStream outputS = System.out; @@ -105,4 +106,19 @@ public class Vault implements VaultInterface { println("Your PWs don´t have special characters anymore."); } } + + public void SetNumbers() { + println("Should you PW have numbers? Type in yes or no."); + + Scanner scan = new Scanner(inputS); + String input = scan.nextLine(); + + if(input.equals("yes")){ + hasNumbers = true; + println("Your PWs contains now numbers."); + }else if(input.equals("no")){ + hasNumbers = false; + println("Your PWs don´t have numbers anymore."); + } + } } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 8aedbc3..5d5fc18 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -142,6 +142,26 @@ public class VaultTest { assertTrue(outputStream.toString().contains("don´t")); } + @Test + void setNumbersTest() { + vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.outputS = outputStream; + vlt.SetNumbers(); + + assertTrue(outputStream.toString().startsWith("Should")); + assertTrue(vlt.hasNumbers = true); + assertTrue(outputStream.toString().contains("contain")); + + vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); + vlt.outputS = outputStream; + vlt.SetNumbers(); + + assertTrue(outputStream.toString().startsWith("Should")); + assertFalse(vlt.hasNumbers = false); + assertTrue(outputStream.toString().contains("don´t")); + } + private ByteArrayInputStream getEmptyStringInputStream() { return new ByteArrayInputStream("".getBytes(StandardCharsets.UTF_8)); } From cd1e7a85a841c1c0b06fcfbaad1a6d8e65723843 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 14:26:05 +0100 Subject: [PATCH 03/12] implemented userName for new credentials --- src/main/java/Vault.java | 8 ++++++++ src/test/java/VaultTest.java | 12 +++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 6b833c3..0bd630b 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -11,6 +11,7 @@ public class Vault implements VaultInterface { public boolean haveCapitals; public boolean hasSpecialChars; public boolean hasNumbers; + public String userName; InputStream inputS = System.in; OutputStream outputS = System.out; @@ -61,6 +62,13 @@ public class Vault implements VaultInterface { public void addCredential(){ + println("Add user name"); + + Scanner scan = new Scanner(inputS); + String input = scan.nextLine(); + + userName = input; + } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 5d5fc18..a4e95ec 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -28,7 +28,17 @@ public class VaultTest { } @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 void showCredential() {vlt.showCredential();} From 6b1d22f773ac8582bb6a1bd9273acf734b501c2d Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:15:03 +0100 Subject: [PATCH 04/12] added vault configure menu wrong input message --- src/main/java/Vault.java | 2 ++ src/test/java/VaultTest.java | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 0bd630b..4c3de46 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -39,6 +39,8 @@ public class Vault implements VaultInterface { if (input.equals("e")) { config = false; + }else if (!input.equals("l")|!input.equals("l")|!input.equals("l")) { + println("Please enter valid key."); } } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index a4e95ec..00642ab 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -79,6 +79,16 @@ public class VaultTest { assertTrue(outputStream.toString().startsWith("Configure:")); } + @Test + void configureMenuWrongInputMessage() { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8)); + vlt.outputS = outputStream; + vlt.configure(); + assertTrue(outputStream.toString().contains("Please")); + } + + @Test void openSetPWLength() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From ac0ce484d3d959585425667ff98f8d7a37ca4ba0 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:34:45 +0100 Subject: [PATCH 05/12] implemented setPWLength in configure menu and refactor --- src/main/java/Vault.java | 12 ++++++------ src/test/java/VaultTest.java | 24 +++++------------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 4c3de46..e80e2f5 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -39,20 +39,20 @@ public class Vault implements VaultInterface { if (input.equals("e")) { config = false; - }else if (!input.equals("l")|!input.equals("l")|!input.equals("l")) { + }else if (input.equals("l")) { + String inputpw = scan.nextLine(); + setPWLength(inputpw); + }else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { println("Please enter valid key."); } } - public void setPWLength(){ + public void setPWLength(String pwLength){ println("Set PW length:"); - Scanner scan = new Scanner(inputS); - String input = scan.nextLine(); - try { - PWLength = Integer.parseInt(input); + PWLength = Integer.parseInt(pwLength); } catch (NumberFormatException e) { println("Please Enter Valid Number."); } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 00642ab..f13a60b 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -90,38 +90,24 @@ public class VaultTest { @Test - void openSetPWLength() { + void openSetPWLengthMenuItem() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - vlt.inputS = new ByteArrayInputStream("12".getBytes(StandardCharsets.UTF_8)); + vlt.inputS = new ByteArrayInputStream("l\n7".getBytes(StandardCharsets.UTF_8)); vlt.outputS = outputStream; - vlt.setPWLength(); - assertTrue(outputStream.toString().startsWith("Set")); + vlt.configure(); + assertEquals(7, vlt.PWLength); } @Test void setPWLength() { - vlt.inputS = new ByteArrayInputStream("7\n".getBytes(StandardCharsets.UTF_8)); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); vlt.outputS = outputStream; - vlt.setPWLength(); + vlt.setPWLength("7"); assertEquals(7, vlt.PWLength); assertTrue(outputStream.toString().contains("now:")); } - @Test - void setPWLengthWrongInput() { - vlt.inputS = new ByteArrayInputStream("T\n".getBytes(StandardCharsets.UTF_8)); - vlt.setPWLength(); - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - vlt.inputS = getEmptyStringInputStream(); - vlt.outputS = outputStream; - - assertThrowsExactly(NoSuchElementException.class, () -> vlt.setPWLength()); - assertTrue(outputStream.toString().startsWith("Set")); - } - @Test void setCapital() { vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); From c2952ab42cba02b47ff7413a6e18b124a62d65b4 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:38:32 +0100 Subject: [PATCH 06/12] setPWLength refactor --- src/main/java/Vault.java | 9 +++------ src/test/java/VaultTest.java | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index e80e2f5..f62f188 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -40,8 +40,9 @@ public class Vault implements VaultInterface { if (input.equals("e")) { config = false; }else if (input.equals("l")) { - String inputpw = scan.nextLine(); - setPWLength(inputpw); + println("Set PW length:"); + String inputPw = scan.nextLine(); + setPWLength(inputPw); }else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { println("Please enter valid key."); } @@ -49,16 +50,12 @@ public class Vault implements VaultInterface { } public void setPWLength(String pwLength){ - println("Set PW length:"); - try { PWLength = Integer.parseInt(pwLength); } catch (NumberFormatException e) { println("Please Enter Valid Number."); } - - println("\nNew PWlength is now: "); } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index f13a60b..3d4e97e 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -96,6 +96,7 @@ public class VaultTest { vlt.outputS = outputStream; vlt.configure(); assertEquals(7, vlt.PWLength); + assertTrue(outputStream.toString().contains("Set")); } @Test From 6d43a35632a18505e9258b5394184e1e2c75a2e7 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:50:51 +0100 Subject: [PATCH 07/12] implemented set capitals in configure menu --- src/main/java/Vault.java | 14 +++++++------- src/test/java/VaultTest.java | 19 ++++++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index f62f188..1cdc10b 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -39,11 +39,15 @@ public class Vault implements VaultInterface { if (input.equals("e")) { config = false; - }else if (input.equals("l")) { + } else if (input.equals("l")) { println("Set PW length:"); String inputPw = scan.nextLine(); setPWLength(inputPw); - }else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { + } else if (input.equals("h")) { + println("Should your PW have capitals? Type in yes or no."); + String inputC = scan.nextLine(); + setPWLength(inputC); + } else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { println("Please enter valid key."); } @@ -83,11 +87,7 @@ public class Vault implements VaultInterface { } - public void setCapital() { - println("Should you PW have capitals? Type in yes or no."); - - Scanner scan = new Scanner(inputS); - String input = scan.nextLine(); + public void setCapital(String input) { if(input.equals("yes")){ haveCapitals = true; diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 3d4e97e..c0a2ad7 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -110,21 +110,26 @@ public class VaultTest { } @Test - void setCapital() { - vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); + void openSetCapitalsMenuItem() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.inputS = new ByteArrayInputStream("h\nyes".getBytes(StandardCharsets.UTF_8)); vlt.outputS = outputStream; - vlt.setCapital(); + vlt.configure(); + assertTrue(vlt.haveCapitals = true); + } + + @Test + void setCapitals() { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + vlt.outputS = outputStream; + vlt.setCapital("yes"); - assertTrue(outputStream.toString().startsWith("Should")); assertTrue(vlt.haveCapitals = true); assertTrue(outputStream.toString().contains("contain")); - vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); vlt.outputS = outputStream; - vlt.setCapital(); + vlt.setCapital("no"); - assertTrue(outputStream.toString().startsWith("Should")); assertFalse(vlt.haveCapitals = false); assertTrue(outputStream.toString().contains("don´t")); } From 881a3234dd873a850ac511ab7c9a2720e8066713 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:51:47 +0100 Subject: [PATCH 08/12] menu refactor --- src/main/java/Vault.java | 3 --- src/test/java/VaultTest.java | 10 ---------- 2 files changed, 13 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 1cdc10b..53cb362 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -47,10 +47,7 @@ public class Vault implements VaultInterface { println("Should your PW have capitals? Type in yes or no."); String inputC = scan.nextLine(); setPWLength(inputC); - } else if (!input.equals("l")|!input.equals("e")|!input.equals("h")) { - println("Please enter valid key."); } - } public void setPWLength(String pwLength){ diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index c0a2ad7..d2a7dac 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -79,16 +79,6 @@ public class VaultTest { assertTrue(outputStream.toString().startsWith("Configure:")); } - @Test - void configureMenuWrongInputMessage() { - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - vlt.inputS = new ByteArrayInputStream("__\n".getBytes(StandardCharsets.UTF_8)); - vlt.outputS = outputStream; - vlt.configure(); - assertTrue(outputStream.toString().contains("Please")); - } - - @Test void openSetPWLengthMenuItem() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); From 05988f788b0cf4aa7f34ca689c594e8d5cc95e95 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 17:59:39 +0100 Subject: [PATCH 09/12] implemented set special char menu item and test refactor --- src/main/java/Vault.java | 14 ++++++++------ src/test/java/VaultTest.java | 18 +++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 53cb362..396e861 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -31,6 +31,8 @@ public class Vault implements VaultInterface { sbcm.append("Configure:\n"); sbcm.append("- Password length: l\n"); sbcm.append("- Have Capitals: h\n"); + sbcm.append("- Have Special Characters: s\n"); + sbcm.append("- Have Numbers: n\n"); sbcm.append("- exit: e\n"); println(sbcm.toString()); @@ -46,7 +48,11 @@ public class Vault implements VaultInterface { } else if (input.equals("h")) { println("Should your PW have capitals? Type in yes or no."); String inputC = scan.nextLine(); - setPWLength(inputC); + setCapital(inputC); + } else if (input.equals("s")){ + println("Should you PW have special characters? Type in yes or no."); + String inputS = scan.nextLine(); + setSpecialChar(inputS); } } @@ -96,11 +102,7 @@ public class Vault implements VaultInterface { } - public void setSpecialChar() { - println("Should you PW have special characters? Type in yes or no."); - - Scanner scan = new Scanner(inputS); - String input = scan.nextLine(); + public void setSpecialChar(String input) { if(input.equals("yes")){ hasSpecialChars = true; diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index d2a7dac..17d5a3d 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -124,22 +124,26 @@ public class VaultTest { assertTrue(outputStream.toString().contains("don´t")); } + @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() { - vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); vlt.outputS = outputStream; - vlt.setSpecialChar(); + vlt.setSpecialChar("yes"); - assertTrue(outputStream.toString().startsWith("Should")); assertTrue(vlt.hasSpecialChars = true); - assertTrue(outputStream.toString().contains("contain")); - vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); vlt.outputS = outputStream; - vlt.setSpecialChar(); + vlt.setSpecialChar("no"); - assertTrue(outputStream.toString().startsWith("Should")); assertFalse(vlt.hasSpecialChars = false); assertTrue(outputStream.toString().contains("don´t")); } From c9968722c80eb8f4fc551ac54146cb7b5beafa24 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 18:03:46 +0100 Subject: [PATCH 10/12] implemented set numbers menu item and test refactor --- src/main/java/Vault.java | 10 +++++----- src/test/java/VaultTest.java | 17 +++++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 396e861..2ed61c7 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -53,6 +53,10 @@ public class Vault implements VaultInterface { println("Should you PW have special characters? Type in yes or no."); String inputS = scan.nextLine(); setSpecialChar(inputS); + } else if (input.equals("n")) { + println("Should you PW have numbers? Type in yes or no."); + String inputN = scan.nextLine(); + setNumbers(input); } } @@ -113,11 +117,7 @@ public class Vault implements VaultInterface { } } - public void SetNumbers() { - println("Should you PW have numbers? Type in yes or no."); - - Scanner scan = new Scanner(inputS); - String input = scan.nextLine(); + public void setNumbers(String input) { if(input.equals("yes")){ hasNumbers = true; diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 17d5a3d..95df60d 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -148,22 +148,27 @@ public class VaultTest { assertTrue(outputStream.toString().contains("don´t")); } + @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() { - vlt.inputS = new ByteArrayInputStream("yes\n".getBytes(StandardCharsets.UTF_8)); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); vlt.outputS = outputStream; - vlt.SetNumbers(); + vlt.setNumbers("yes"); - assertTrue(outputStream.toString().startsWith("Should")); assertTrue(vlt.hasNumbers = true); assertTrue(outputStream.toString().contains("contain")); - vlt.inputS = new ByteArrayInputStream("no\n".getBytes(StandardCharsets.UTF_8)); vlt.outputS = outputStream; - vlt.SetNumbers(); + vlt.setNumbers("no"); - assertTrue(outputStream.toString().startsWith("Should")); assertFalse(vlt.hasNumbers = false); assertTrue(outputStream.toString().contains("don´t")); } From 34d6de43c7ae431c75e84faa5cf6f00321f53259 Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 20:29:31 +0100 Subject: [PATCH 11/12] typo refactor --- src/main/java/Vault.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 2ed61c7..025e215 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -30,8 +30,8 @@ public class Vault implements VaultInterface { sbcm.append("Configure:\n"); sbcm.append("- Password length: l\n"); - sbcm.append("- Have Capitals: h\n"); - sbcm.append("- Have Special Characters: s\n"); + sbcm.append("- Have capitals: h\n"); + sbcm.append("- Have special characters: s\n"); sbcm.append("- Have Numbers: n\n"); sbcm.append("- exit: e\n"); @@ -64,10 +64,10 @@ public class Vault implements VaultInterface { try { PWLength = Integer.parseInt(pwLength); } catch (NumberFormatException e) { - println("Please Enter Valid Number."); + println("Please enter valid number."); } - println("\nNew PWlength is now: "); + println("\nNew password length is now: "); } @@ -75,9 +75,9 @@ public class Vault implements VaultInterface { println("Add user name"); Scanner scan = new Scanner(inputS); - String input = scan.nextLine(); + scan.nextLine(); - userName = input; + userName = scan.nextLine(); } From a18ebb743871694e4c56ad5403a5b5894ed1495b Mon Sep 17 00:00:00 2001 From: fdai6352 Date: Wed, 16 Feb 2022 20:38:19 +0100 Subject: [PATCH 12/12] temporarily deleted addCredential --- src/main/java/Vault.java | 7 ------- src/test/java/VaultTest.java | 12 +----------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/main/java/Vault.java b/src/main/java/Vault.java index 025e215..84f5ccf 100644 --- a/src/main/java/Vault.java +++ b/src/main/java/Vault.java @@ -72,13 +72,6 @@ public class Vault implements VaultInterface { public void addCredential(){ - println("Add user name"); - - Scanner scan = new Scanner(inputS); - scan.nextLine(); - - userName = scan.nextLine(); - } diff --git a/src/test/java/VaultTest.java b/src/test/java/VaultTest.java index 95df60d..77f4b7b 100644 --- a/src/test/java/VaultTest.java +++ b/src/test/java/VaultTest.java @@ -28,17 +28,7 @@ public class VaultTest { } @Test - 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); - - } + void addCredentialTest() { vlt.addCredential();} @Test void showCredential() {vlt.showCredential();}