def test_dnsblocklistgroup_get(self): group = DnsBlocklistGroup() group.add_dnsbl('test1.example.com') group.add_dnsbl('test2.example.com') group.add_dnsbl('test3.example.com') DNSResolver.query('4.3.2.1.test1.example.com', 'A').InAnyOrder('one').AndReturn(FakeAsyncResult()) DNSResolver.query('4.3.2.1.test2.example.com', 'A').InAnyOrder('one').AndRaise( DNSError(ARES_ENOTFOUND)) DNSResolver.query('4.3.2.1.test3.example.com', 'A').InAnyOrder('one').AndReturn(FakeAsyncResult()) DNSResolver.query('8.7.6.5.test1.example.com', 'A').InAnyOrder('two').AndRaise( DNSError(ARES_ENOTFOUND)) DNSResolver.query('8.7.6.5.test2.example.com', 'A').InAnyOrder('two').AndRaise( DNSError(ARES_ENOTFOUND)) DNSResolver.query('8.7.6.5.test3.example.com', 'A').InAnyOrder('two').AndRaise( DNSError(ARES_ENOTFOUND)) self.mox.ReplayAll() self.assertEqual(set(['test1.example.com', 'test3.example.com']), group.get('1.2.3.4')) self.assertNotIn('5.6.7.8', group)
def test_dnsblocklistgroup_get(self): group = DnsBlocklistGroup() group.add_dnsbl('test1.example.com') group.add_dnsbl('test2.example.com') group.add_dnsbl('test3.example.com') DNSResolver.query('4.3.2.1.test1.example.com', 'A').InAnyOrder('one').AndReturn(FakeAsyncResult()) DNSResolver.query('4.3.2.1.test2.example.com', 'A').InAnyOrder('one').AndRaise(DNSError(ARES_ENOTFOUND)) DNSResolver.query('4.3.2.1.test3.example.com', 'A').InAnyOrder('one').AndReturn(FakeAsyncResult()) DNSResolver.query('8.7.6.5.test1.example.com', 'A').InAnyOrder('two').AndRaise(DNSError(ARES_ENOTFOUND)) DNSResolver.query('8.7.6.5.test2.example.com', 'A').InAnyOrder('two').AndRaise(DNSError(ARES_ENOTFOUND)) DNSResolver.query('8.7.6.5.test3.example.com', 'A').InAnyOrder('two').AndRaise(DNSError(ARES_ENOTFOUND)) self.mox.ReplayAll() self.assertEqual(set(['test1.example.com', 'test3.example.com']), group.get('1.2.3.4')) self.assertNotIn('5.6.7.8', group)
def test_dnsblocklistgroup_get(self): group = DnsBlocklistGroup() group.add_dnsbl('test1.example.com') group.add_dnsbl('test2.example.com') group.add_dnsbl('test3.example.com') dns.resolver.query('4.3.2.1.test1.example.com', 'A').InAnyOrder('one') dns.resolver.query('4.3.2.1.test2.example.com', 'A').InAnyOrder('one').AndRaise(dns.resolver.NXDOMAIN) dns.resolver.query('4.3.2.1.test3.example.com', 'A').InAnyOrder('one') dns.resolver.query('8.7.6.5.test1.example.com', 'A').InAnyOrder('two').AndRaise(dns.resolver.NXDOMAIN) dns.resolver.query('8.7.6.5.test2.example.com', 'A').InAnyOrder('two').AndRaise(dns.resolver.NXDOMAIN) dns.resolver.query('8.7.6.5.test3.example.com', 'A').InAnyOrder('two').AndRaise(dns.resolver.NXDOMAIN) self.mox.ReplayAll() self.assertEqual(set(['test1.example.com', 'test3.example.com']), group.get('1.2.3.4')) self.assertNotIn('5.6.7.8', group)
def test_dnsblocklistgroup_get(self): group = DnsBlocklistGroup() group.add_dnsbl("test1.example.com") group.add_dnsbl("test2.example.com") group.add_dnsbl("test3.example.com") dns_resolver.query("4.3.2.1.test1.example.com", "A").InAnyOrder("one") dns_resolver.query("4.3.2.1.test2.example.com", "A").InAnyOrder("one").AndRaise(NXDOMAIN) dns_resolver.query("4.3.2.1.test3.example.com", "A").InAnyOrder("one") dns_resolver.query("8.7.6.5.test1.example.com", "A").InAnyOrder("two").AndRaise(NXDOMAIN) dns_resolver.query("8.7.6.5.test2.example.com", "A").InAnyOrder("two").AndRaise(NXDOMAIN) dns_resolver.query("8.7.6.5.test3.example.com", "A").InAnyOrder("two").AndRaise(NXDOMAIN) self.mox.ReplayAll() self.assertEqual(set(["test1.example.com", "test3.example.com"]), group.get("1.2.3.4")) self.assertNotIn("5.6.7.8", group)