]> granicus.if.org Git - pdns/commitdiff
rec: Add a small regression test for 'max-cache-bogus-ttl'
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 13 Feb 2019 15:04:57 +0000 (16:04 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 13 Feb 2019 15:04:57 +0000 (16:04 +0100)
regression-tests.recursor-dnssec/basicDNSSEC.py
regression-tests.recursor-dnssec/recursortests.py
regression-tests.recursor-dnssec/test_Flags.py
regression-tests.recursor-dnssec/test_TTL.py [new file with mode: 0644]

index a630fac178c8fb5f1759ee7b1be8693fd2488a69..e754dffa8488eb312ad6533b4cedc5669797b95f 100644 (file)
@@ -11,16 +11,6 @@ class BasicDNSSEC(RecursorTest):
         confdir = os.path.join('configs', cls._confdir)
         cls.wipeRecursorCache(confdir)
 
-    @classmethod
-    def sendQuery(self, name, rdtype, useTCP=False):
-        """Helper function that creates the query"""
-        msg = dns.message.make_query(name, rdtype, want_dnssec=True)
-        msg.flags |= dns.flags.AD
-
-        if useTCP:
-            return self.sendTCPQuery(msg)
-        return self.sendUDPQuery(msg)
-
     def testSecureAnswer(self):
         res = self.sendQuery('ns.secure.example.', 'A')
         expected = dns.rrset.from_text('ns.secure.example.', 0, dns.rdataclass.IN, 'A', '{prefix}.10'.format(prefix=self._PREFIX))
index 491aa895470442a9c49174ea4721996e1b9893fb..46ca97c4677ba9b3d873d324d4f184d0f8e29f1d 100644 (file)
@@ -804,3 +804,22 @@ distributor-threads=1""".format(confdir=confdir,
         print(expectedResponse)
         print(response)
         self.assertEquals(response, expectedResponse)
+
+    @classmethod
+    def sendQuery(cls, name, rdtype, useTCP=False):
+        """Helper function that creates the query"""
+        msg = dns.message.make_query(name, rdtype, want_dnssec=True)
+        msg.flags |= dns.flags.AD
+
+        if useTCP:
+            return cls.sendTCPQuery(msg)
+        return cls.sendUDPQuery(msg)
+
+    def createQuery(self, name, rdtype, flags, ednsflags):
+        """Helper function that creates the query with the specified flags.
+        The flags need to be strings (no checking is performed atm)"""
+        msg = dns.message.make_query(name, rdtype)
+        msg.flags = dns.flags.from_text(flags)
+        msg.flags += dns.flags.from_text('RD')
+        msg.use_edns(edns=0, ednsflags=dns.flags.edns_from_text(ednsflags))
+        return msg
index 22b63c89d891db5ebe0f9c660ed7d53dbc01d740..a550b9001d52aa13d16c59605779120b6da1938f 100644 (file)
@@ -76,15 +76,6 @@ class TestFlags(RecursorTest):
             cls._recursor = recursor
             cls.tearDownRecursor()
 
-    def createQuery(self, name, rdtype, flags, ednsflags):
-        """Helper function that creates the query with the specified flags.
-        The flags need to be strings (no checking is performed atm)"""
-        msg = dns.message.make_query(name, rdtype)
-        msg.flags = dns.flags.from_text(flags)
-        msg.flags += dns.flags.from_text('RD')
-        msg.use_edns(edns=0, ednsflags=dns.flags.edns_from_text(ednsflags))
-        return msg
-
     def getQueryForSecure(self, flags='', ednsflags=''):
         return self.createQuery('ns1.example.', 'A', flags, ednsflags)
 
diff --git a/regression-tests.recursor-dnssec/test_TTL.py b/regression-tests.recursor-dnssec/test_TTL.py
new file mode 100644 (file)
index 0000000..6825157
--- /dev/null
@@ -0,0 +1,30 @@
+import dns
+import os
+from recursortests import RecursorTest
+
+class testBogusMaxTTL(RecursorTest):
+    _confdir = 'BogusMaxTTL'
+
+    _config_template = """dnssec=validate
+max-cache-bogus-ttl=5"""
+
+    @classmethod
+    def setUp(cls):
+        confdir = os.path.join('configs', cls._confdir)
+        cls.wipeRecursorCache(confdir)
+
+    def testBogusCheckDisabled(self):
+        # first query with CD=0, so we should get a ServFail
+        query = self.createQuery('ted.bogus.example.', 'A', 'AD', 'DO')
+        res = self.sendUDPQuery(query)
+        self.assertRcodeEqual(res, dns.rcode.SERVFAIL)
+
+        # then with CD=1 so we should get the A + RRSIG
+        # check that we correctly applied the maximum TTL when caching Bogus entries
+        query = self.createQuery('ted.bogus.example.', 'A', 'AD CD', 'DO')
+        res = self.sendUDPQuery(query)
+        self.assertMessageHasFlags(res, ['CD', 'QR', 'RA', 'RD'], ['DO'])
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertEquals(len(res.answer), 2)
+        for ans in res.answer:
+            self.assertLessEqual(ans.ttl, 5)