Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
strehle committed Oct 24, 2023
1 parent d99061a commit 6b5b6fa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public static PasswordValidator validator(GenericPasswordPolicy<?> policy,
MessageResolver messageResolver) {
List<Rule> rules = new ArrayList<>();

//length is always a rule
int minLength = Math.max(0, policy.getMinLength());
int minLength = policy.getMinLength()>0 ? policy.getMinLength() : 0;
int maxLength = policy.getMaxLength()>0 ? policy.getMaxLength() : Integer.MAX_VALUE;
rules.add(new LengthRule(minLength, maxLength));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ void setUp() {
}

@Test
void testEmptyClientSecretAllowed() {
void defaultPolicyAcceptsEmptySecret() {
zone.getConfig().setClientSecretPolicy(defaultPolicy);
validator.validate(TEST_EMPTY_SECRET);
}

@Test
void testEmptyClientSecretForbidden() {
void strictPolicyRejectsEmptySecret() {
zone.getConfig().setClientSecretPolicy(strictPolicy);
assertThrows(InvalidClientSecretException.class, () -> validator.validate(TEST_EMPTY_SECRET));
}
Expand Down

0 comments on commit 6b5b6fa

Please sign in to comment.