diff options
| author | Bob Halley <halley@dnspython.org> | 2022-03-23 06:06:05 -0700 |
|---|---|---|
| committer | Bob Halley <halley@dnspython.org> | 2022-03-23 06:06:05 -0700 |
| commit | 44233c7d644a41e1fb90ad6de67b355dd279f6f4 (patch) | |
| tree | 0545e5b35ec04a2ac4aae415cb5a761e9faad065 /tests | |
| parent | b1e9bb7d64bf7cae97a02e64b38f3ba33a73947a (diff) | |
| download | dnspython-44233c7d644a41e1fb90ad6de67b355dd279f6f4.tar.gz | |
test padding in DoH
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_doh.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test_doh.py b/tests/test_doh.py index 35cb1d3..bae28dc 100644 --- a/tests/test_doh.py +++ b/tests/test_doh.py @@ -25,6 +25,7 @@ try: except Exception: _have_ssl = False +import dns.edns import dns.message import dns.query import dns.rdatatype @@ -69,6 +70,11 @@ KNOWN_ANYCAST_DOH_RESOLVER_URLS = [ # 'https://dns11.quad9.net/dns-query', ] +KNOWN_PAD_AWARE_DOH_RESOLVER_URLS = [ + "https://cloudflare-dns.com/dns-query", + "https://dns.google/dns-query", +] + # Some tests require the internet to be available to run, so let's # skip those if it's not there. _network_available = True @@ -256,6 +262,21 @@ class DNSOverHTTPSTestCaseHttpx(unittest.TestCase): self.assertTrue("8.8.8.8" in seen) self.assertTrue("8.8.4.4" in seen) + def test_padded_get(self): + nameserver_url = random.choice(KNOWN_PAD_AWARE_DOH_RESOLVER_URLS) + q = dns.message.make_query("example.com.", dns.rdatatype.A, use_edns=0, pad=128) + r = dns.query.https( + q, nameserver_url, session=self.session, post=False, timeout=4 + ) + self.assertTrue(q.is_response(r)) + # the response should have a padding option + self.assertIsNotNone(r.opt) + has_pad = False + for o in r.opt[0].options: + if o.otype == dns.edns.OptionType.PADDING: + has_pad = True + self.assertTrue(has_pad) + if __name__ == "__main__": unittest.main() |
