protected Matching createMatching(List<String> lowerSanitizedInputs) { return new Matching(lowerSanitizedInputs); }
protected Matching createMatching(List<String> lowerSanitizedInputs) { return new Matching(lowerSanitizedInputs); }
Strength baseAnalysis = Scoring.mostGuessableMatchSequence(baseToken, new Matching(new ArrayList<String>()).omnimatch(baseToken)); List<Match> baseMatches = baseAnalysis.getSequence(); double baseGuesses = baseAnalysis.getGuesses();
Strength baseAnalysis = Scoring.mostGuessableMatchSequence(baseToken, new Matching(new ArrayList<String>()).omnimatch(baseToken)); List<Match> baseMatches = baseAnalysis.getSequence(); double baseGuesses = baseAnalysis.getGuesses();
@Test public void testOmnimatch() throws Exception { assertEquals(0, new Matching(new ArrayList<String>()).omnimatch("").size()); String password = "r0sebudmaelstrom11/20/91aaaa"; List<Match> matches = new Matching(new ArrayList<String>()).omnimatch(password); Map<Pattern, Integer[]> testMatches = new HashMap<>(); testMatches.put(Pattern.Dictionary, new Integer[]{0, 6}); testMatches.put(Pattern.Dictionary, new Integer[]{7, 15}); testMatches.put(Pattern.Date, new Integer[]{16, 23}); testMatches.put(Pattern.Repeat, new Integer[]{24, 27}); for (Map.Entry<Pattern, Integer[]> testMatch : testMatches.entrySet()) { Pattern patternName = testMatch.getKey(); int i = testMatch.getValue()[0]; int j = testMatch.getValue()[1]; boolean included = false; for (Match match : matches) { if (match.i == i && match.j == j && match.pattern == patternName) included = true; } String msg = String.format("for %s, matches a %s token at [%s, %s]", password, patternName.value(), i, j); assertTrue(msg, included); } } }
@Test public void testRepeatGuesses() throws Exception { double baseGuesses = Scoring.mostGuessableMatchSequence( baseToken, new Matching().omnimatch(baseToken)).getGuesses(); Match match = new Match.Builder(Pattern.Repeat, 0, 0, token) .baseToken(baseToken) .baseGuesses(baseGuesses) .repeatCount(repeatCount) .build(); double expectedGuesses = baseGuesses * repeatCount; String msg = String.format("the repeat pattern '%s' has guesses of %s", token, expectedGuesses); assertEquals(msg, expectedGuesses, new RepeatGuess().exec(match), 0.0); }