]>
Commit | Line | Data |
---|---|---|
c51c551e OM |
1 | import dns |
2 | import os | |
3 | import time | |
4 | from recursortests import RecursorTest | |
5 | ||
6 | class testOOOTCP(RecursorTest): | |
7 | _confdir = 'OOOTCP' | |
8 | ||
4709a495 | 9 | _config_template = """dnssec=validate |
c51c551e OM |
10 | """ |
11 | ||
12 | @classmethod | |
13 | def generateRecursorConfig(cls, confdir): | |
14 | super(testOOOTCP, cls).generateRecursorConfig(confdir) | |
15 | ||
4709a495 | 16 | def testOOOVeryBasic(self): |
c51c551e OM |
17 | expected = {} |
18 | queries = [] | |
a79f06c4 | 19 | for zone in ['5.delay1.example.', '0.delay2.example.']: |
c51c551e | 20 | expected[zone] = dns.rrset.from_text(zone, 0, dns.rdataclass.IN, 'TXT', 'a') |
4709a495 | 21 | query = dns.message.make_query(zone, 'TXT', want_dnssec=True) |
c51c551e OM |
22 | query.flags |= dns.flags.AD |
23 | queries.append(query) | |
24 | ||
25 | ress = self.sendTCPQueries(queries) | |
26 | ||
27 | self.assertEqual(len(ress), len(expected)) | |
28 | ||
29 | i = 0 | |
a79f06c4 | 30 | for exp in [expected['0.delay2.example.'], expected['5.delay1.example.']]: |
c51c551e OM |
31 | print('ress0') |
32 | print(ress[i].answer[0].to_text()) | |
33 | print('exp') | |
34 | print(exp.to_text()) | |
4709a495 | 35 | self.assertMessageIsAuthenticated(ress[i]) |
c51c551e | 36 | self.assertRRsetInAnswer(ress[i], exp) |
4709a495 | 37 | self.assertMatchingRRSIGInAnswer(ress[i], exp) |
c51c551e OM |
38 | i = i + 1 |
39 | ||
4709a495 | 40 | def testOOOTimeout(self): |
c51c551e OM |
41 | expected = {} |
42 | queries = [] | |
a79f06c4 | 43 | for zone in ['25.delay1.example.', '1.delay2.example.']: |
4709a495 | 44 | query = dns.message.make_query(zone, 'TXT', want_dnssec=True) |
c51c551e OM |
45 | query.flags |= dns.flags.AD |
46 | queries.append(query) | |
47 | ||
48 | ress = self.sendTCPQueries(queries) | |
a79f06c4 | 49 | |
c51c551e | 50 | self.assertEqual(len(ress), 2) |
a79f06c4 | 51 | exp = dns.rrset.from_text('1.delay2.example.', 0, dns.rdataclass.IN, 'TXT', 'a') |
c51c551e | 52 | self.assertRRsetInAnswer(ress[0], exp) |
4709a495 | 53 | self.assertMatchingRRSIGInAnswer(ress[0], exp) |
c51c551e OM |
54 | self.assertRcodeEqual(ress[1], dns.rcode.SERVFAIL) |
55 | ||
56 | # Let the auth timeout happen to not disturb other tests | |
4709a495 | 57 | # this can happen if the auth is single-threaded |
c51c551e OM |
58 | time.sleep(1) |
59 |