]>
Commit | Line | Data |
---|---|---|
2b54bebb PL |
1 | import dns |
2 | import os | |
3 | import socket | |
4 | import struct | |
5 | import threading | |
6 | import time | |
7 | ||
8 | from recursortests import RecursorTest | |
9 | from twisted.internet.protocol import DatagramProtocol | |
10 | from twisted.internet import reactor | |
11 | ||
12 | ednsBufferReactorRunning = False | |
13 | ||
14 | class EDNSTest(RecursorTest): | |
15 | """ | |
16 | These tests are designed to check if we respond correctly to EDNS queries | |
17 | from clients. Note that buffer-size tests go into test_EDNSBufferSize | |
18 | """ | |
19 | _confdir = 'EDNS' | |
20 | ||
21 | def testEDNSUnknownOpt(self): | |
22 | """ | |
23 | Ensure the recursor does not reply with an unknown option when one is | |
24 | sent in the query | |
25 | """ | |
26 | query = dns.message.make_query('version.bind.', 'TXT', 'CH', use_edns=0, | |
27 | payload=4096) | |
28 | unknownOpt = dns.edns.GenericOption(65005, b'1234567890') | |
29 | query.options = [unknownOpt] | |
30 | response = self.sendUDPQuery(query) | |
31 | self.assertRcodeEqual(response, dns.rcode.NOERROR) | |
32 | self.assertEqual(response.options, []) | |
33 | ||
34 | def testEDNSBadVers(self): | |
35 | """ | |
6cf96227 PL |
36 | Ensure the rcode is BADVERS when we send an unsupported EDNS version and |
37 | the query is not processed any further. | |
2b54bebb PL |
38 | """ |
39 | query = dns.message.make_query('version.bind.', 'TXT', 'CH', use_edns=5, | |
40 | payload=4096) | |
41 | response = self.sendUDPQuery(query) | |
42 | self.assertRcodeEqual(response, dns.rcode.BADVERS) | |
6cf96227 | 43 | self.assertEqual(response.answer, []) |