]> granicus.if.org Git - pdns/commitdiff
Add simple NODATA tests
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 28 Apr 2016 14:57:53 +0000 (16:57 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Thu, 28 Apr 2016 14:57:53 +0000 (16:57 +0200)
regression-tests.recursor-dnssec/basicDNSSEC.py
regression-tests.recursor-dnssec/recursortests.py

index 72915691307d7e4728242deddc44241e983b9a81..36f858ba6d9ad335eca48912af28b7bcfe4a213a 100644 (file)
@@ -107,3 +107,29 @@ class BasicDNSSEC(RecursorTest):
         self.assertRcodeEqual(res, dns.rcode.NXDOMAIN)
         self.assertMatchingRRSIGInAnswer(res, expectedCNAME)
         self.assertMessageIsAuthenticated(res)
+
+    def testSecureNoData(self):
+        res = self.sendQuery('host1.secure.example.', 'AAAA')
+
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertAnswerEmpty(res)
+        self.assertAuthorityHasSOA(res)
+        self.assertMessageIsAuthenticated(res)
+
+    def testSecureCNAMENoData(self):
+        res = self.sendQuery('cname.secure.example.', 'AAAA')
+        expectedCNAME = dns.rrset.from_text('cname.secure.example.', 0, dns.rdataclass.IN, 'CNAME', 'host1.secure.example.')
+
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertMatchingRRSIGInAnswer(res, expectedCNAME)
+        self.assertAuthorityHasSOA(res)
+        self.assertMessageIsAuthenticated(res)
+
+    def testSecureWildCardNoData(self):
+        res = self.sendQuery('something.cnamewildcard.secure.example.', 'AAAA')
+        expectedCNAME = dns.rrset.from_text('something.cnamewildcard.secure.example.', 0, dns.rdataclass.IN, 'CNAME', 'host1.secure.example.')
+
+        self.assertRcodeEqual(res, dns.rcode.NOERROR)
+        self.assertMatchingRRSIGInAnswer(res, expectedCNAME)
+        self.assertAuthorityHasSOA(res)
+        self.assertMessageIsAuthenticated(res)
index ea1767e14410c3bb5e708234a60f6981d78baf96..dd61f7a5258a1d3a67c0950f67680be941c138de 100644 (file)
@@ -96,6 +96,7 @@ secure.example.          3600 IN NS   ns.secure.example.
 ns.secure.example.       3600 IN A    {prefix}.9
 
 host1.secure.example.    3600 IN A    192.0.2.2
+cname.secure.example.    3600 IN CNAME host1.secure.example.
 
 host1.sub.secure.example. 3600 IN A    192.0.2.11
 
@@ -684,3 +685,16 @@ distributor-threads=1""".format(confdir=confdir,
             wantedRcode = dns.rcode._by_value[rcode]
 
             raise AssertionError("Rcode for %s is %s, expected %s." % (msg.question[0].to_text(), msgRcode, wantedRcode))
+
+    def assertAuthorityHasSOA(self, msg):
+        if not isinstance(msg, dns.message.Message):
+            raise TypeError("msg is not a dns.message.Message but a %s" % type(msg))
+
+        found = False
+        for rrset in msg.authority:
+            if rrset.rdtype == dns.rdatatype.SOA:
+                found = True
+                break
+
+        if not found:
+            raise AssertionError("No SOA record found in the authority section:\n%s" % msg.to_text())