Skip to content

Commit 970d6e6

Browse files
committed
improve password rule check testing
1 parent 8114ad1 commit 970d6e6

File tree

3 files changed

+331
-96
lines changed

3 files changed

+331
-96
lines changed

server/src/main/java/password/pwm/error/ErrorInformation.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,7 @@
2727
import java.io.Serializable;
2828
import java.time.Instant;
2929
import java.util.Arrays;
30-
import java.util.Collections;
31-
import java.util.List;
3230
import java.util.Locale;
33-
import java.util.Objects;
34-
import java.util.Set;
35-
import java.util.stream.Collectors;
3631

3732
/**
3833
* An ErrorInformation is a package of error data generated within PWM. Error information includes an error code
@@ -176,23 +171,5 @@ public ErrorInformation wrapWithNewErrorCode( final PwmError pwmError )
176171
return this;
177172
}
178173
return new ErrorInformation( pwmError, this.getDetailedErrorMsg() );
179-
180-
}
181-
182-
public static boolean listsContainSameErrors( final List<ErrorInformation> errorInformation1, final List<ErrorInformation> errorInformation2 )
183-
{
184-
Objects.requireNonNull( errorInformation1 );
185-
Objects.requireNonNull( errorInformation2 );
186-
return extractErrorSet( errorInformation1 ).equals( extractErrorSet( errorInformation2 ) );
187-
}
188-
189-
private static Set<PwmError> extractErrorSet( final List<ErrorInformation> errors )
190-
{
191-
if ( errors != null )
192-
{
193-
return errors.stream().map( ErrorInformation::getError ).collect( Collectors.toSet() );
194-
}
195-
196-
return Collections.emptySet();
197174
}
198175
}

server/src/main/java/password/pwm/util/password/PasswordRuleChecks.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
import java.util.Set;
5353
import java.util.regex.Pattern;
5454

55+
/**
56+
* Contains validation logic for the most of the "internal" {@link PwmPasswordRule} rules.
57+
*/
5558
public class PasswordRuleChecks
5659
{
5760
private static final PwmLogger LOGGER = PwmLogger.forClass( PasswordRuleChecks.class );
@@ -101,7 +104,7 @@ List<ErrorInformation> test(
101104
) );
102105

103106

104-
public static List<ErrorInformation> extendedPolicyRuleChecker(
107+
public static List<ErrorInformation> extendedPolicyRuleChecker(
105108
final PwmApplication pwmApplication,
106109
final PwmPasswordPolicy policy,
107110
final String password,
@@ -318,7 +321,7 @@ public List<ErrorInformation> test( final String password, final String oldPassw
318321
final int maxLower = ruleHelper.readIntValue( PwmPasswordRule.MaximumLowerCase );
319322
if ( maxLower > 0 && numberOfLowerChars > maxLower )
320323
{
321-
errorList.add( new ErrorInformation( PwmError.PASSWORD_TOO_MANY_UPPER ) );
324+
errorList.add( new ErrorInformation( PwmError.PASSWORD_TOO_MANY_LOWER ) );
322325
}
323326
}
324327
return Collections.unmodifiableList( errorList );

0 commit comments

Comments
 (0)