mirror of https://github.com/fail2ban/fail2ban
test case fix (always sort result of `DNSUtils.textToIp`, because order of result from `socket.getaddrinfo` is undefined (system depended)
parent
3d3735706b
commit
e0924e0d1b
|
@ -1357,9 +1357,11 @@ class DNSUtilsNetworkTests(unittest.TestCase):
|
|||
res = DNSUtils.textToIp('www.example.com', 'no')
|
||||
self.assertEqual(res, [])
|
||||
res = DNSUtils.textToIp('www.example.com', 'warn')
|
||||
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
# sort ipaddr, IPv4 is always smaller as IPv6
|
||||
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
res = DNSUtils.textToIp('www.example.com', 'yes')
|
||||
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
# sort ipaddr, IPv4 is always smaller as IPv6
|
||||
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
|
||||
def testTextToIp(self):
|
||||
# Test hostnames
|
||||
|
@ -1371,7 +1373,8 @@ class DNSUtilsNetworkTests(unittest.TestCase):
|
|||
for s in hostnames:
|
||||
res = DNSUtils.textToIp(s, 'yes')
|
||||
if s == 'www.example.com':
|
||||
self.assertEqual(res, ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
# sort ipaddr, IPv4 is always smaller as IPv6
|
||||
self.assertEqual(sorted(res), ['93.184.216.34', '2606:2800:220:1:248:1893:25c8:1946'])
|
||||
else:
|
||||
self.assertEqual(res, [])
|
||||
|
||||
|
|
Loading…
Reference in New Issue