Skip to content

Commit

Permalink
XWIKI-21898: Reset password doesn't work properly with rule to force …
Browse files Browse the repository at this point in the history
…a symbol

  * Fix wrong regular expression for checking symbol rule in password

(cherry picked from commit c7e88a0)
  • Loading branch information
surli committed Feb 19, 2024
1 parent 26a855d commit 662bf48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ enum PasswordRules
/**
* When one symbol character is mandatory.
*/
ONE_SYMBOL_CHARACTER(".*(_\\W)+.*"),
ONE_SYMBOL_CHARACTER(".*[_\\W]+.*"),

/**
* When one number character is mandatory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
String symbolNumberNoSpace6Chars = "_/3434";
String onlyUpper3Chars = "FOO";
String onlyUpper6Chars = "FOOOOO";
String isolatedSymbol = "bar@bar";

return Stream.of(
// Length 3, no rules
Expand All @@ -536,6 +537,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(3, noRules, symbolNumberNoSpace6Chars, true),
Arguments.of(3, noRules, onlyUpper3Chars, true),
Arguments.of(3, noRules, onlyUpper6Chars, true),
Arguments.of(3, noRules, isolatedSymbol, true),
// length 6, no rules
Arguments.of(6, noRules, onlyLower3Chars, false),
Arguments.of(6, noRules, onlyLower6Chars, true),
Expand All @@ -551,6 +553,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, noRules, symbolNumberNoSpace6Chars, true),
Arguments.of(6, noRules, onlyUpper3Chars, false),
Arguments.of(6, noRules, onlyUpper6Chars, true),
Arguments.of(6, noRules, isolatedSymbol, true),
// length 6, lower mandatory
Arguments.of(6, lowerMandatory, onlyLower3Chars, false),
Arguments.of(6, lowerMandatory, onlyLower6Chars, true),
Expand All @@ -566,6 +569,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, lowerMandatory, symbolNumberNoSpace6Chars, false),
Arguments.of(6, lowerMandatory, onlyUpper3Chars, false),
Arguments.of(6, lowerMandatory, onlyUpper6Chars, false),
Arguments.of(6, lowerMandatory, isolatedSymbol, true),
// length 6, upper mandatory
Arguments.of(6, upperMandatory, onlyLower3Chars, false),
Arguments.of(6, upperMandatory, onlyLower6Chars, false),
Expand All @@ -581,6 +585,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, upperMandatory, symbolNumberNoSpace6Chars, false),
Arguments.of(6, upperMandatory, onlyUpper3Chars, false),
Arguments.of(6, upperMandatory, onlyUpper6Chars, true),
Arguments.of(6, upperMandatory, isolatedSymbol, false),
// length 6, number mandatory
Arguments.of(6, numberMandatory, onlyLower3Chars, false),
Arguments.of(6, numberMandatory, onlyLower6Chars, false),
Expand All @@ -596,6 +601,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, numberMandatory, symbolNumberNoSpace6Chars, true),
Arguments.of(6, numberMandatory, onlyUpper3Chars, false),
Arguments.of(6, numberMandatory, onlyUpper6Chars, false),
Arguments.of(6, numberMandatory, isolatedSymbol, false),
// length 6, symbol mandatory
Arguments.of(6, symbolMandatory, onlyLower3Chars, false),
Arguments.of(6, symbolMandatory, onlyLower6Chars, false),
Expand All @@ -611,6 +617,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, symbolMandatory, symbolNumberNoSpace6Chars, true),
Arguments.of(6, symbolMandatory, onlyUpper3Chars, false),
Arguments.of(6, symbolMandatory, onlyUpper6Chars, false),
Arguments.of(6, symbolMandatory, isolatedSymbol, true),
// length 6, upper and number mandatory
Arguments.of(6, upperAndNumberMandatory, onlyLower3Chars, false),
Arguments.of(6, upperAndNumberMandatory, onlyLower6Chars, false),
Expand All @@ -626,6 +633,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, upperAndNumberMandatory, symbolNumberNoSpace6Chars, false),
Arguments.of(6, upperAndNumberMandatory, onlyUpper3Chars, false),
Arguments.of(6, upperAndNumberMandatory, onlyUpper6Chars, false),
Arguments.of(6, upperAndNumberMandatory, isolatedSymbol, false),
// length 6, upper and lower mandatory
Arguments.of(6, lowerAndUpperMandatory, onlyLower3Chars, false),
Arguments.of(6, lowerAndUpperMandatory, onlyLower6Chars, false),
Expand All @@ -641,6 +649,7 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, lowerAndUpperMandatory, symbolNumberNoSpace6Chars, false),
Arguments.of(6, lowerAndUpperMandatory, onlyUpper3Chars, false),
Arguments.of(6, lowerAndUpperMandatory, onlyUpper6Chars, false),
Arguments.of(6, lowerAndUpperMandatory, isolatedSymbol, false),
// length 6, all rules
Arguments.of(6, allRules, onlyLower3Chars, false),
Arguments.of(6, allRules, onlyLower6Chars, false),
Expand All @@ -656,9 +665,11 @@ private static Stream<Arguments> provideArgumentsForIsPasswordCompliantWithRegis
Arguments.of(6, allRules, symbolNumberNoSpace6Chars, false),
Arguments.of(6, allRules, onlyUpper3Chars, false),
Arguments.of(6, allRules, onlyUpper6Chars, false),
Arguments.of(6, allRules, isolatedSymbol, false),
// length 13, all rules
Arguments.of(13, allRules, lowerUpperSymbolNumberSpace12Chars, false),
Arguments.of(13, allRules, lowerUpperSymbolNumberSpaceAccents14Chars, true)
Arguments.of(13, allRules, lowerUpperSymbolNumberSpaceAccents14Chars, true),
Arguments.of(13, allRules, isolatedSymbol, false)
);
}
}

0 comments on commit 662bf48

Please sign in to comment.