summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2021-10-24 06:10:58 -0700
committerBob Halley <halley@dnspython.org>2021-10-24 06:10:58 -0700
commite298b0d231db0444746886252c9a48ce8fce364d (patch)
tree390e42f87c96f646085354c3f7db799591e606e0 /tests
parentdb8f8459664d38df0683c7946928f6431918bf9a (diff)
downloaddnspython-e298b0d231db0444746886252c9a48ce8fce364d.tar.gz
Validate resolver nameservers when set [Issue #699].
Diffstat (limited to 'tests')
-rw-r--r--tests/test_async.py8
-rw-r--r--tests/test_doh.py6
-rw-r--r--tests/test_resolver.py10
3 files changed, 10 insertions, 14 deletions
diff --git a/tests/test_async.py b/tests/test_async.py
index cad7e20..0782c7a 100644
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -216,14 +216,6 @@ class AsyncTests(unittest.TestCase):
return await dns.asyncresolver.canonical_name(name)
self.assertEqual(self.async_run(run), cname)
- def testResolverBadScheme(self):
- res = dns.asyncresolver.Resolver(configure=False)
- res.nameservers = ['bogus://dns.google/dns-query']
- async def run():
- answer = await res.resolve('dns.google', 'A')
- def bad():
- self.async_run(run)
- self.assertRaises(dns.resolver.NoNameservers, bad)
def testZoneForName1(self):
async def run():
diff --git a/tests/test_doh.py b/tests/test_doh.py
index 793a500..835e07d 100644
--- a/tests/test_doh.py
+++ b/tests/test_doh.py
@@ -139,12 +139,6 @@ class DNSOverHTTPSTestCase(unittest.TestCase):
self.assertTrue('8.8.8.8' in seen)
self.assertTrue('8.8.4.4' in seen)
- def test_resolver_bad_scheme(self):
- res = dns.resolver.Resolver(configure=False)
- res.nameservers = ['bogus://dns.google/dns-query']
- def bad():
- answer = res.resolve('dns.google', 'A')
- self.assertRaises(dns.resolver.NoNameservers, bad)
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
index b2a47d2..ecd1bf2 100644
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -700,6 +700,16 @@ class LiveResolverTests(unittest.TestCase):
cname = dns.name.from_text('dangling-target.dnspython.org')
self.assertEqual(dns.resolver.canonical_name(name), cname)
+ def testNameserverSetting(self):
+ res = dns.resolver.Resolver(configure=False)
+ ns = ['1.2.3.4', '::1', 'https://ns.example']
+ res.nameservers = ns[:]
+ self.assertEqual(res.nameservers, ns)
+ for ns in ['999.999.999.999', 'ns.example.', 'bogus://ns.example']:
+ with self.assertRaises(ValueError):
+ res.nameservers = [ns]
+
+
class PollingMonkeyPatchMixin(object):
def setUp(self):
self.__native_selector_class = dns.query._selector_class