]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.recursor-dnssec/test_AnyBind.py
Merge pull request #13927 from rgacogne/fix-fclose-warnings
[thirdparty/pdns.git] / regression-tests.recursor-dnssec / test_AnyBind.py
CommitLineData
3a817a78
OM
1import dns
2import os
3import socket
4from recursortests import RecursorTest
5
6class testAnyBind(RecursorTest):
7 _confdir = 'AnyBind'
8
9 _config_template = """dnssec=validate
10 local-address=0.0.0.0
11auth-zones=authzone.example=configs/%s/authzone.zone""" % _confdir
12
13 @classmethod
14 def generateRecursorConfig(cls, confdir):
15 authzonepath = os.path.join(confdir, 'authzone.zone')
16 with open(authzonepath, 'w') as authzone:
17 authzone.write("""$ORIGIN authzone.example.
18@ 3600 IN SOA {soa}
19@ 3600 IN A 192.0.2.88
20""".format(soa=cls._SOA))
21 super(testAnyBind, cls).generateRecursorConfig(confdir)
22
23 @classmethod
24 def setUpSockets(cls):
25 print("Setting up UDP socket..")
26 cls._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
27 cls._sock.settimeout(2.0)
28 cls._sock.connect(("127.0.0.2", cls._recursorPort))
29
30 def testA(self):
31 """Test to see if we get a reply from 127.0.0.2 if rec is bound to ANY address"""
32 expected = dns.rrset.from_text('ns.secure.example.', 0, dns.rdataclass.IN, 'A', '{prefix}.9'.format(prefix=self._PREFIX))
33 query = dns.message.make_query('ns.secure.example', 'A', want_dnssec=True)
34 query.flags |= dns.flags.AD
35
36 res = self.sendUDPQuery(query)
37
38 self.assertMessageIsAuthenticated(res)
39 self.assertRRsetInAnswer(res, expected)
40 self.assertMatchingRRSIGInAnswer(res, expected)
41