summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-06-19 09:56:28 -0700
committerBob Halley <halley@dnspython.org>2020-06-19 09:56:28 -0700
commit0a7a6210d8a55f2151818652b4245c81101f402b (patch)
treee7644b9d48273ddfe583fd10fc062c0398982215
parent1a227524c42ec3e75cc62043b275c6d85ad5d0dd (diff)
downloaddnspython-0a7a6210d8a55f2151818652b4245c81101f402b.tar.gz
improve e164 coverage
-rw-r--r--tests/test_name.py5
-rw-r--r--tests/test_resolver.py9
2 files changed, 13 insertions, 1 deletions
diff --git a/tests/test_name.py b/tests/test_name.py
index 6856970..a7cb483 100644
--- a/tests/test_name.py
+++ b/tests/test_name.py
@@ -886,5 +886,10 @@ class NameTestCase(unittest.TestCase):
text = dns.e164.to_e164(n)
self.assertEqual(text, e)
+ def testBadEnumToE164(self):
+ n = dns.name.from_text('2.1.2.q.5.5.5.0.5.6.1.e164.arpa.')
+ self.assertRaises(dns.exception.SyntaxError,
+ lambda: dns.e164.to_e164(n))
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/test_resolver.py b/tests/test_resolver.py
index cf5118f..46024e3 100644
--- a/tests/test_resolver.py
+++ b/tests/test_resolver.py
@@ -598,7 +598,11 @@ class NaptrNanoNameserver(Server):
response.set_rcode(dns.rcode.REFUSED)
response.flags |= dns.flags.RA
try:
- if message.question[0].rdtype == dns.rdatatype.NAPTR and \
+ zero_subdomain = dns.e164.from_e164('0')
+ if message.question[0].name.is_subdomain(zero_subdomain):
+ response.set_rcode(dns.rcode.NXDOMAIN)
+ response.flags |= dns.flags.AA
+ elif message.question[0].rdtype == dns.rdatatype.NAPTR and \
message.question[0].rdclass == dns.rdataclass.IN:
rrs = dns.rrset.from_text(message.question[0].name, 300,
'IN', 'NAPTR',
@@ -627,3 +631,6 @@ class NanoTests(unittest.TestCase):
self.assertEqual(answer[0].service, b'')
self.assertEqual(answer[0].regexp, b'')
self.assertEqual(answer[0].replacement, dns.name.root)
+ def nxdomain():
+ answer = dns.e164.query('0123456789', ['e164.arpa'], res)
+ self.assertRaises(dns.resolver.NXDOMAIN, nxdomain)