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