|
|
@ -222,12 +222,24 @@ class GetFailures(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
class DNSUtilsTests(unittest.TestCase): |
|
|
|
class DNSUtilsTests(unittest.TestCase): |
|
|
|
|
|
|
|
|
|
|
|
def testTextToIp(self, useDns): |
|
|
|
def testUseDns(self): |
|
|
|
# Bogus addresses which should have no DNS matches |
|
|
|
res = DNSUtils.textToIp('www.example.com', 'no') |
|
|
|
bogus = [ |
|
|
|
self.assertEqual(res, None) |
|
|
|
|
|
|
|
res = DNSUtils.textToIp('www.example.com', 'warn') |
|
|
|
|
|
|
|
self.assertEqual(res, ['192.0.43.10']) |
|
|
|
|
|
|
|
res = DNSUtils.textToIp('www.example.com', 'yes') |
|
|
|
|
|
|
|
self.assertEqual(res, ['192.0.43.10']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def testTextToIp(self): |
|
|
|
|
|
|
|
# Test hostnames |
|
|
|
|
|
|
|
hostnames = [ |
|
|
|
|
|
|
|
'www.example.com' |
|
|
|
'doh1.2.3.4.buga.xxxxx.yyy.invalid', |
|
|
|
'doh1.2.3.4.buga.xxxxx.yyy.invalid', |
|
|
|
'1.2.3.4.buga.xxxxx.yyy.invalid', |
|
|
|
'1.2.3.4.buga.xxxxx.yyy.invalid', |
|
|
|
] |
|
|
|
] |
|
|
|
for s in bogus: |
|
|
|
for s in hostnames: |
|
|
|
res = DNSUtils.textToIp(s, useDns) |
|
|
|
res = DNSUtils.textToIp(s, 'yes') |
|
|
|
|
|
|
|
if s is 'www.example.com': |
|
|
|
|
|
|
|
self.assertEqual(res, ['192.0.43.10']) |
|
|
|
|
|
|
|
else: |
|
|
|
self.assertEqual(res, []) |
|
|
|
self.assertEqual(res, []) |
|
|
|