]>
Commit | Line | Data |
---|---|---|
1c9c001c RG |
1 | #!/usr/bin/env python |
2 | import base64 | |
3 | import dns | |
4 | import os | |
5 | import unittest | |
6 | ||
7 | from dnsdisttests import DNSDistTest | |
8 | ||
9 | import pycurl | |
10 | from io import BytesIO | |
11 | ||
12 | @unittest.skipIf('SKIP_DOH_TESTS' in os.environ, 'DNS over HTTPS tests are disabled') | |
13 | class DNSDistDOHTest(DNSDistTest): | |
14 | ||
1c9c001c RG |
15 | def getHeaderValue(self, name): |
16 | for header in self._response_headers.decode().splitlines(False): | |
17 | values = header.split(':') | |
18 | key = values[0] | |
19 | if key.lower() == name.lower(): | |
20 | return values[1].strip() | |
21 | return None | |
22 | ||
23 | def checkHasHeader(self, name, value): | |
24 | got = self.getHeaderValue(name) | |
25 | self.assertEqual(got, value) | |
26 | ||
27 | def checkNoHeader(self, name): | |
28 | self.checkHasHeader(name, None) | |
29 | ||
30 | @classmethod | |
31 | def setUpClass(cls): | |
32 | ||
33 | # for some reason, @unittest.skipIf() is not applied to derived classes with some versions of Python | |
34 | if 'SKIP_DOH_TESTS' in os.environ: | |
35 | raise unittest.SkipTest('DNS over HTTPS tests are disabled') | |
36 | ||
37 | cls.startResponders() | |
38 | cls.startDNSDist() | |
39 | cls.setUpSockets() | |
40 | ||
41 | print("Launching tests..") |