Browse Source

testIPToName: switch from google to one of the root-servers (8.8.4.4 seems not to have rDNS anymore)

pull/3381/head
sebres 11 months ago
parent
commit
6fb89d1709
  1. 10
      fail2ban/tests/filtertestcase.py
  2. 3
      fail2ban/tests/utils.py

10
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)

3
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')

Loading…
Cancel
Save