]>
Commit | Line | Data |
---|---|---|
98194c31 O |
1 | import dns |
2 | import os | |
3 | import subprocess | |
4 | from recursortests import RecursorTest | |
5 | ||
6 | class testSimpleDoT(RecursorTest): | |
7 | """ | |
8 | This tests DoT to auth server in a very basic way and is dependent on powerdns.com nameservers having DoT enabled. | |
9 | """ | |
10 | ||
11 | _confdir = 'SimpleDoT' | |
12 | _config_template = """ | |
13 | dnssec=validate | |
14 | dot-to-auth-names=powerdns.com | |
15 | """ | |
16 | ||
17 | _roothints = None | |
18 | ||
19 | @classmethod | |
20 | def setUpClass(cls): | |
21 | ||
22 | # we don't need all the auth stuff | |
23 | cls.setUpSockets() | |
24 | cls.startResponders() | |
25 | ||
26 | confdir = os.path.join('configs', cls._confdir) | |
27 | cls.createConfigDir(confdir) | |
28 | ||
29 | cls.generateRecursorConfig(confdir) | |
30 | cls.startRecursor(confdir, cls._recursorPort) | |
31 | ||
32 | def testA(self): | |
33 | expected = dns.rrset.from_text('www.powerdns.com.', 0, dns.rdataclass.IN, 'A', '188.166.104.92') | |
34 | query = dns.message.make_query('www.powerdns.com', 'A', want_dnssec=True) | |
35 | query.flags |= dns.flags.AD | |
36 | ||
37 | res = self.sendUDPQuery(query) | |
38 | ||
39 | self.assertMessageIsAuthenticated(res) | |
40 | self.assertRRsetInAnswer(res, expected) | |
41 | self.assertMatchingRRSIGInAnswer(res, expected) | |
42 | ||
43 | rec_controlCmd = [os.environ['RECCONTROL'], | |
44 | '--config-dir=%s' % 'configs/' + self._confdir, | |
45 | 'get dot-outqueries'] | |
46 | try: | |
47 | ret = subprocess.check_output(rec_controlCmd, stderr=subprocess.STDOUT) | |
48 | self.assertNotEqual(ret, b'UNKNOWN\n') | |
49 | self.assertNotEqual(ret, b'0\n') | |
50 | ||
51 | except subprocess.CalledProcessError as e: | |
52 | print(e.output) | |
53 | raise | |
54 | ||
55 | rec_controlCmd = [os.environ['RECCONTROL'], | |
56 | '--config-dir=%s' % 'configs/' + self._confdir, | |
57 | 'get tcp-outqueries'] | |
58 | try: | |
59 | ret = subprocess.check_output(rec_controlCmd, stderr=subprocess.STDOUT) | |
60 | self.assertEqual(ret, b'0\n') | |
61 | ||
62 | except subprocess.CalledProcessError as e: | |
63 | print(e.output) | |
64 | raise | |
65 |