]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.recursor-dnssec/test_EDNS.py
Merge pull request #7350 from sjvs/patch-2
[thirdparty/pdns.git] / regression-tests.recursor-dnssec / test_EDNS.py
CommitLineData
2b54bebb
PL
1import dns
2import os
3import socket
4import struct
5import threading
6import time
7
8from recursortests import RecursorTest
9from twisted.internet.protocol import DatagramProtocol
10from twisted.internet import reactor
11
12ednsBufferReactorRunning = False
13
14class 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, [])