public void UsesTheUserInputDictionary()
        {
            var matcher = new DictionaryMatcher("user_inputs", new[] { "foo", "bar" });

            var result = matcher.MatchPassword("foobar").OfType <DictionaryMatch>().ToList();

            var expected = new[]
            {
                new DictionaryMatch
                {
                    DictionaryName = "user_inputs",
                    i           = 0,
                    j           = 2,
                    MatchedWord = "foo",
                    Rank        = 1,
                    Reversed    = false,
                    L33t        = false,
                    Token       = "foo",
                },
                new DictionaryMatch
                {
                    DictionaryName = "user_inputs",
                    i           = 3,
                    j           = 5,
                    MatchedWord = "bar",
                    Rank        = 2,
                    Reversed    = false,
                    L33t        = false,
                    Token       = "bar",
                },
            };

            result.Should().BeEquivalentTo(expected);
        }
        public void DictionaryTest()
        {
            var dm = new DictionaryMatcher("test", "test_dictionary.txt");

            var res = dm.MatchPassword("NotInDictionary");

            Assert.AreEqual(0, res.Count());

            res = dm.MatchPassword("choreography");
            Assert.AreEqual(1, res.Count());

            res = dm.MatchPassword("ChOrEograPHy");
            Assert.AreEqual(1, res.Count());


            var leet = new L33tMatcher(dm);

            res = leet.MatchPassword("3mu");
            Assert.AreEqual(1, res.Count());

            res = leet.MatchPassword("3mupr4nce|egume");
        }
        public void MatchesWithProvidedUserInputDictionary()
        {
            var matcher = new DictionaryMatcher("user", new[] { "foo", "bar" });
            var result  = matcher.MatchPassword("foobar").OfType <DictionaryMatch>().Where(m => m.DictionaryName == "user").ToList();

            result.Should().HaveCount(2);

            result[0].Token.Should().Be("foo");
            result[0].MatchedWord.Should().Be("foo");
            result[0].Rank.Should().Be(1);
            result[0].i.Should().Be(0);
            result[0].j.Should().Be(2);

            result[1].Token.Should().Be("bar");
            result[1].MatchedWord.Should().Be("bar");
            result[1].Rank.Should().Be(2);
            result[1].i.Should().Be(3);
            result[1].j.Should().Be(5);
        }
        public void UsesTheDefaultDictionaries()
        {
            var result = matcherTv.MatchPassword("wow").OfType <DictionaryMatch>().ToList();

            var expected = new[]
            {
                new DictionaryMatch
                {
                    DictionaryName = "us_tv_and_film",
                    i           = 0,
                    j           = 2,
                    MatchedWord = "wow",
                    Rank        = 322,
                    Reversed    = false,
                    L33t        = false,
                    Token       = "wow",
                },
            };

            result.Should().BeEquivalentTo(expected);
        }
        private List <DictionaryMatch> RunMatches(string word)
        {
            var result = matcher1.MatchPassword(word).Concat(matcher2.MatchPassword(word));

            return(result.OfType <DictionaryMatch>().ToList());
        }
Beispiel #6
0
        public void DictionaryMatch(string word, int count)
        {
            var dm = new DictionaryMatcher("test", "test_dictionary.txt");

            dm.MatchPassword(word).Should().HaveCount(count);
        }