From: Remi Gacogne Date: Fri, 11 Jun 2021 15:02:38 +0000 (+0200) Subject: dnsdist: Add regression tests for the XFR end detection feature X-Git-Tag: dnsdist-1.7.0-alpha1~124^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4639c3f5bfcd13e4185c97a3f72f259ebba85c38;p=thirdparty%2Fpdns.git dnsdist: Add regression tests for the XFR end detection feature --- diff --git a/regression-tests.dnsdist/test_AXFR.py b/regression-tests.dnsdist/test_AXFR.py index 6bc5004614..c4e43c7bad 100644 --- a/regression-tests.dnsdist/test_AXFR.py +++ b/regression-tests.dnsdist/test_AXFR.py @@ -165,6 +165,156 @@ class TestAXFR(DNSDistTest): self.assertEqual(query, receivedQuery) self.assertEqual(len(receivedResponses), len(responses)) + def testThreePlusTrailingAXFR(self): + """ + AXFR: Three messages including the final SOA, plus a trailing one + """ + name = 'threeplustrailing.axfr.tests.powerdns.com.' + query = dns.message.make_query(name, 'AXFR', 'IN') + responses = [] + soa = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.SOA, + 'ns.' + name + ' hostmaster.' + name + ' 1 3600 3600 3600 60') + + # the SOA starts the AXFR + response = dns.message.make_response(query) + response.answer.append(soa) + responses.append(response) + + # one A + response = dns.message.make_response(query) + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.A, + '192.0.2.1')) + responses.append(response) + + # one AAAA + response = dns.message.make_response(query) + rrset = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.AAAA, + '2001:DB8::1') + response.answer.append(rrset) + responses.append(response) + + # one TXT then the SOA that ends the AXFR + response = dns.message.make_response(query) + rrset = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.TXT, + "Some text") + response.answer.append(rrset) + response.answer.append(soa) + responses.append(response) + + # and we add a final, dummy TXT message that will + # be sent by the backend but that dnsdist should not + # pass along to the client + response = dns.message.make_response(query) + rrset = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.TXT, + 'dummy') + response.answer.append(rrset) + responses.append(response) + + (receivedQuery, receivedResponses) = self.sendTCPQueryWithMultipleResponses(query, responses) + receivedQuery.id = query.id + self.assertEqual(query, receivedQuery) + self.assertEqual(len(receivedResponses), len(responses) - 1) + + def testThreePlusTrailingIXFR(self): + """ + IXFR: Three messages including the final SOA, plus a trailing one + """ + name = 'threeplustrailing.ixfr.tests.powerdns.com.' + query = dns.message.make_query(name, 'AXFR', 'IN') + responses = [] + + finalSoa = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.SOA, + 'ns.' + name + ' hostmaster.' + name + ' 3 3600 3600 3600 60') + + # the final SOA starts the AXFR, with first an update from 1 to 2 (one removal, two additions) + response = dns.message.make_response(query) + response.answer.append(finalSoa) + # update from 1 to 2 + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.SOA, + 'ns.' + name + ' hostmaster.' + name + ' 1 3600 3600 3600 60')) + # one removal + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.A, + '192.0.2.1')) + # then additions + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.SOA, + 'ns.' + name + ' hostmaster.' + name + ' 2 3600 3600 3600 60')) + # new message in the middle of the additions + responses.append(response) + response = dns.message.make_response(query) + + response.answer.append(dns.rrset.from_text_list(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.A, + ['192.0.2.2', '192.0.2.3'])) + # done with 1 -> 2 + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.SOA, + 'ns.' + name + ' hostmaster.' + name + ' 2 3600 3600 3600 60')) + # new message + responses.append(response) + response = dns.message.make_response(query) + + # then upgrade to 3 + # no removals + response.answer.append(finalSoa) + + # and one addition + response.answer.append(dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.A, + '192.0.2.4')) + # and the final SOA + response.answer.append(finalSoa) + responses.append(response) + + # and we add a final, dummy TXT message that will + # be sent by the backend but that dnsdist should not + # pass along to the client + response = dns.message.make_response(query) + rrset = dns.rrset.from_text(name, + 60, + dns.rdataclass.IN, + dns.rdatatype.TXT, + 'dummy') + response.answer.append(rrset) + responses.append(response) + + (receivedQuery, receivedResponses) = self.sendTCPQueryWithMultipleResponses(query, responses) + receivedQuery.id = query.id + self.assertEqual(query, receivedQuery) + self.assertEqual(len(receivedResponses), len(responses) - 1) + # def testFourNoFirstSOAAXFR(self): # """ # AXFR: Four messages, no SOA in the first one