summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2020-07-25 06:29:08 -0700
committerBob Halley <halley@dnspython.org>2020-07-25 06:29:08 -0700
commit55ab7215cfc2300410deeda60beff5eedcebdcad (patch)
tree81438173cc5509d0a57fe6490628eff93cad0fe0 /tests
parentb904694b12193a5782d5cee46dcc74d43483e1eb (diff)
downloaddnspython-55ab7215cfc2300410deeda60beff5eedcebdcad.tar.gz
even on errors where we tolerate no question, check question if present
Diffstat (limited to 'tests')
-rw-r--r--tests/test_message.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test_message.py b/tests/test_message.py
index bfc137f..f004b92 100644
--- a/tests/test_message.py
+++ b/tests/test_message.py
@@ -368,6 +368,13 @@ class MessageTestCase(unittest.TestCase):
q.additional = [rrset]
self.assertEqual(q.sections[3], [rrset])
+ def test_is_a_response_empty_question(self):
+ q = dns.message.make_query('www.dnspython.org.', 'a')
+ r = dns.message.make_response(q)
+ r.question = []
+ r.set_rcode(dns.rcode.FORMERR)
+ self.assertTrue(q.is_response(r))
+
def test_not_a_response(self):
q = dns.message.QueryMessage(id=1)
self.assertFalse(q.is_response(q))
@@ -384,6 +391,11 @@ class MessageTestCase(unittest.TestCase):
q2.id = 1
r = dns.message.make_response(q2)
self.assertFalse(q1.is_response(r))
+ # Now set rcode to FORMERR and check again. It should still
+ # not be a response as we check the question section for FORMERR
+ # if it is present.
+ r.set_rcode(dns.rcode.FORMERR)
+ self.assertFalse(q1.is_response(r))
# Test the other case of differing questions, where there is
# something in the response's question section that is not in
# the question's. We have to do multiple questions to test