Пример #1
0
        public void TestListComments()
        {
            IPBanConfig config = IPBanConfig.LoadFromXml("<?xml version='1.0'?><configuration>" +
                                                         "<appSettings><add key='Whitelist' value='99.99.99.99?TestIP?2020-05-25," +
                                                         "88.88.88.88?TestIP2?2020-05-24' /></appSettings></configuration>",
                                                         DefaultDnsLookup.Instance);

            Assert.AreEqual(string.Join(",", config.Whitelist.OrderBy(i => i)), "88.88.88.88,99.99.99.99");
            Assert.IsTrue(config.IsWhitelisted("99.99.99.99"));
            Assert.IsTrue(config.IsWhitelisted("88.88.88.88"));
            Assert.IsFalse(config.IsWhitelisted("77.77.77.77"));
        }
Пример #2
0
        public void TestBlacklistDns()
        {
            IPBanConfig config = IPBanConfig.LoadFromXml("<?xml version='1.0'?><configuration>" +
                                                         "<appSettings><add key='Blacklist' value='test.com' /></appSettings></configuration>",
                                                         this);

            Assert.IsFalse(config.IsWhitelisted("99.88.77.66"));
            Assert.IsTrue(config.IsBlackListed("99.88.77.66"));
        }