]> git.ipfire.org Git - thirdparty/pdns.git/blame - regression-tests.recursor-dnssec/test_TTL.py
Merge pull request #13927 from rgacogne/fix-fclose-warnings
[thirdparty/pdns.git] / regression-tests.recursor-dnssec / test_TTL.py
CommitLineData
c5b0071d
RG
1import dns
2import os
3from recursortests import RecursorTest
4
5class testBogusMaxTTL(RecursorTest):
6 _confdir = 'BogusMaxTTL'
7
8 _config_template = """dnssec=validate
9max-cache-bogus-ttl=5"""
10
11 @classmethod
12 def setUp(cls):
13 confdir = os.path.join('configs', cls._confdir)
14 cls.wipeRecursorCache(confdir)
15
16 def testBogusCheckDisabled(self):
17 # first query with CD=0, so we should get a ServFail
18 query = self.createQuery('ted.bogus.example.', 'A', 'AD', 'DO')
19 res = self.sendUDPQuery(query)
20 self.assertRcodeEqual(res, dns.rcode.SERVFAIL)
21
22 # then with CD=1 so we should get the A + RRSIG
23 # check that we correctly applied the maximum TTL when caching Bogus entries
24 query = self.createQuery('ted.bogus.example.', 'A', 'AD CD', 'DO')
25 res = self.sendUDPQuery(query)
26 self.assertMessageHasFlags(res, ['CD', 'QR', 'RA', 'RD'], ['DO'])
27 self.assertRcodeEqual(res, dns.rcode.NOERROR)
4bfebc93 28 self.assertEqual(len(res.answer), 2)
c5b0071d
RG
29 for ans in res.answer:
30 self.assertLessEqual(ans.ttl, 5)