Esempio n. 1
0
        public void Check_should_identify_dangerous_urls()
        {
            // Arrange
            var sut = new SimpleRegexUrlChecker(new[]
            {
                @"^.*jpe082ver\.info.*$",
                @"^.*ntfl-promo2017.info.*$"
            });
            var url1 = "http://www.jpe082ver.info/test";
            var url2 = "https://antfl-promo2017.info";

            // Act
            var result1 = sut.Check(url1);

            // Assert
            Assert.AreEqual(url1, result1.Url);
            Assert.AreEqual(ThreatType.Unknow, result1.ThreatType);
            Assert.IsFalse(result1.IsSafe);

            // Act
            var result2 = sut.Check(url2);

            // Assert
            Assert.AreEqual(url2, result2.Url);
            Assert.AreEqual(ThreatType.Unknow, result2.ThreatType);
            Assert.IsFalse(result2.IsSafe);
        }
Esempio n. 2
0
        public void SimpleRegexUrlChecker_should_respond_to_rules_updating()
        {
            // Arrange
            var rules = new SimpleRegexRules();
            var sut   = new SimpleRegexUrlChecker(rules);
            var url   = "http://www.jpe082ver.info/test";

            Assert.IsTrue(sut.Check(url).IsSafe);

            // Act
            rules.Update(new[] { new Regex(@"^.*jpe082ver\.info.*$") });
            var result = sut.Check(url);

            // Assert
            Assert.AreEqual(url, result.Url);
            Assert.AreEqual(ThreatType.Unknow, result.ThreatType);
            Assert.IsFalse(result.IsSafe);
        }
Esempio n. 3
0
        public void Check_should_identify_safe_urls()
        {
            // Arrange
            var sut = new SimpleRegexUrlChecker(new[]
            {
                @"^.*jpe082ver\.info.*$",
                @"^.*ntfl-promo2017\.info.*$"
            });
            var url = "http://www.safe.info/test";

            // Act
            var result = sut.Check(url);

            // Assert
            Assert.AreEqual(url, result.Url);
            Assert.IsTrue(result.IsSafe);
            Assert.AreEqual(ThreatType.NoThreat, result.ThreatType);
        }