You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because ConfigurationBuilder.getDefaultXYZ returns the internal instances (and because of the way the documentation suggests to add stuff to the configuration builder), one can easily add for example matchers multiple times.
public int estimate(String password) {
List<PasswordMatcher> matchers = ConfigurationBuilder.getDefaultPasswordMatchers();
matchers.add(new PasswordMatcher() {
@Override
public List<Match> match(Configuration configuration, String password) {
System.out.println("Called with: " + password);
return new ArrayList<>();
}
});
Configuration config = new ConfigurationBuilder()
.setPasswordMatchers(matchers)
.createConfiguration();
Nbvcxz tester = new Nbvcxz(config)
Result result = tester.estimate(password);
return result.getBasicScore(); // Yes I've seen that you dislike this, but just to illustrate! :)
}
Running the above once will print "Called with ...". Running it a second time will print "Called with ..." twice, a third time trice, a fourth time will print it four times and so on.
One can get around this by either creating the configuration once (and not every time a test is made) or by wrapping the return value of ConfiguratioBuilder.getDefaultPasswordMatchers() in a new ArrayList.
This is not a big bug but given the documentation I spent a good half hour scratching my head as to why I was getting multiple calls to my "PasswordMatcher".
Best Regards,
Per-Erik
The text was updated successfully, but these errors were encountered:
Yeah, it absolutely would. I just got back from a two week vacation, so I have a bit to catch up on, but will try and get this sorted as quickly as I can. Pull requests are always welcome if someone gets to this before me.
Because ConfigurationBuilder.getDefaultXYZ returns the internal instances (and because of the way the documentation suggests to add stuff to the configuration builder), one can easily add for example matchers multiple times.
Running the above once will print "Called with ...". Running it a second time will print "Called with ..." twice, a third time trice, a fourth time will print it four times and so on.
One can get around this by either creating the configuration once (and not every time a test is made) or by wrapping the return value of ConfiguratioBuilder.getDefaultPasswordMatchers() in a new ArrayList.
This is not a big bug but given the documentation I spent a good half hour scratching my head as to why I was getting multiple calls to my "PasswordMatcher".
Best Regards,
Per-Erik
The text was updated successfully, but these errors were encountered: