diff --git a/fail2ban/tests/filtertestcase.py b/fail2ban/tests/filtertestcase.py index 8027846e..8617e233 100644 --- a/fail2ban/tests/filtertestcase.py +++ b/fail2ban/tests/filtertestcase.py @@ -2200,11 +2200,13 @@ class DNSUtilsNetworkTests(unittest.TestCase): def testIpToName(self): #unittest.F2B.SkipIfNoNetwork() - res = DNSUtils.ipToName('8.8.4.4') - self.assertTrue(res.endswith(('.google', '.google.com'))) + self.assertEqual(DNSUtils.ipToName('87.142.124.10'), 'test-host') + self.assertEqual(DNSUtils.ipToName('2001:db8::ffff'), 'test-other') + res = DNSUtils.ipToName('199.9.14.201') + self.assertTrue(res.endswith(('.isi.edu', '.b.root-servers.org'))) # same as above, but with IPAddr: - res = DNSUtils.ipToName(IPAddr('8.8.4.4')) - self.assertTrue(res.endswith(('.google', '.google.com'))) + res = DNSUtils.ipToName(IPAddr('199.9.14.201')) + self.assertTrue(res.endswith(('.isi.edu', '.b.root-servers.org'))) # invalid ip (TEST-NET-1 according to RFC 5737) res = DNSUtils.ipToName('192.0.2.0') self.assertEqual(res, None) diff --git a/fail2ban/tests/utils.py b/fail2ban/tests/utils.py index bd4c7e02..ef908ddb 100644 --- a/fail2ban/tests/utils.py +++ b/fail2ban/tests/utils.py @@ -311,7 +311,8 @@ def initTests(opts): # precache all ip to dns used in test cases: c.set('192.0.2.888', None) c.set('8.8.4.4', 'dns.google') - c.set('8.8.4.4', 'dns.google') + c.set('8.8.8.8', 'dns.google') + c.set('199.9.14.201', 'b-2017.b.root-servers.org') # precache all dns to ip's used in test cases: c = DNSUtils.CACHE_nameToIp c.clear = lambda: logSys.warning('clear CACHE_nameToIp is disabled in test suite')