File tree Expand file tree Collapse file tree 3 files changed +45
-1
lines changed
kata/5-kyu/regex-password-validation Expand file tree Collapse file tree 3 files changed +45
-1
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,4 @@ You need to write regex that will validate a password to make sure it meets the
66* contains a lowercase letter
77* contains an uppercase letter
88* contains a digit
9- * only contains alphanumeric characters (note that ` '_' ` is not alphanumeric)
9+ * only contains alphanumeric characters (note that ` '_' ` is not alphanumeric)
Original file line number Diff line number Diff line change 1+ interface PasswordRegex {
2+ String REGEX = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\ d)[a-zA-Z\\ d]{6,}$" ;
3+ }
Original file line number Diff line number Diff line change 1+ import static org .junit .jupiter .api .Assertions .assertFalse ;
2+ import static org .junit .jupiter .api .Assertions .assertTrue ;
3+
4+ import org .junit .jupiter .params .ParameterizedTest ;
5+ import org .junit .jupiter .params .provider .ValueSource ;
6+
7+ class SolutionTest {
8+ @ ParameterizedTest
9+ @ ValueSource (strings = {
10+ "fjd3IR9" ,
11+ "4fdg5Fj3" ,
12+ "djI38D55" ,
13+ "123abcABC" ,
14+ "ABC123abc" ,
15+ "Password123"
16+ })
17+ void valid (String password ) {
18+ assertTrue (password .matches (PasswordRegex .REGEX ));
19+ }
20+
21+ @ ParameterizedTest
22+ @ ValueSource (strings = {
23+ "ghdfj32" ,
24+ "DSJKHD23" ,
25+ "dsF43" ,
26+ "DHSJdhjsU" ,
27+ "fjd3IR9.;" ,
28+ "fjd3 IR9" ,
29+ "djI3_8D55" ,
30+ "@@" ,
31+ "JHD5FJ53" ,
32+ "!fdjn345" ,
33+ "jfkdfj3j" ,
34+ "123" ,
35+ "abc" ,
36+ ""
37+ })
38+ void invalid (String password ) {
39+ assertFalse (password .matches (PasswordRegex .REGEX ));
40+ }
41+ }
You can’t perform that action at this time.
0 commit comments