From: Charles-Henri Bruyand Date: Fri, 9 Feb 2024 10:27:22 +0000 (+0100) Subject: ixfrdist: add a simple test for outgoing notify X-Git-Tag: auth-4.9.0-beta1^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ccd8001109054347ceb49f626a83e7eef769cb3;p=thirdparty%2Fpdns.git ixfrdist: add a simple test for outgoing notify --- diff --git a/regression-tests.ixfrdist/ixfrdisttests.py b/regression-tests.ixfrdist/ixfrdisttests.py index 03638a4eb9..851e59799c 100644 --- a/regression-tests.ixfrdist/ixfrdisttests.py +++ b/regression-tests.ixfrdist/ixfrdisttests.py @@ -46,9 +46,11 @@ failed-soa-retry: 3 if cls._config_domains is not None: conf.write("domains:\n") - for domain, master in cls._config_domains.items(): - conf.write(" - domain: %s\n" % (domain)) - conf.write(" master: %s\n" % (master)) + for item in cls._config_domains: + conf.write(" - domain: %s\n" % (item['domain'])) + conf.write(" master: %s\n" % (item['master'])) + if ('notify' in item) : + conf.write(" notify: %s\n" % (item['notify'])) ixfrdistcmd = [os.environ['IXFRDISTBIN'], '--config', conffile, '--debug'] diff --git a/regression-tests.ixfrdist/test_IXFR.py b/regression-tests.ixfrdist/test_IXFR.py index 159d85d4fb..dbc1dc906f 100644 --- a/regression-tests.ixfrdist/test_IXFR.py +++ b/regression-tests.ixfrdist/test_IXFR.py @@ -2,6 +2,7 @@ import dns import dns.serial import time import itertools +import socket from ixfrdisttests import IXFRDistTest from xfrserver.xfrserver import AXFRServer @@ -56,10 +57,15 @@ class IXFRDistBasicTest(IXFRDistTest): global xfrServerPort _xfrDone = 0 - _config_domains = { 'example': '127.0.0.1:' + str(xfrServerPort), # zone for actual XFR testing - 'example2': '127.0.0.1:1', # bogus port is intentional - zone is intentionally unloadable - # example3 # intentionally absent for 'unconfigured zone' testing - 'example4': '127.0.0.1:' + str(xfrServerPort) } # for testing how ixfrdist deals with getting the wrong zone on XFR + _config_domains = [ + # zone for actual XFR testing + {"domain" : "example", "master" : "127.0.0.1:" + str(xfrServerPort), 'notify' : "127.0.0.1:" + str(xfrServerPort + 1)}, + # bogus port is intentional - zone is intentionally unloadable + {"domain" : "example2", "master" : "127.0.0.1:1"}, + # for testing how ixfrdist deals with getting the wrong zone on XFR + {"domain" : "example4", "master" : '127.0.0.1:' + str(xfrServerPort)}, + + ] _loaded_serials = [] @classmethod @@ -112,7 +118,7 @@ class IXFRDistBasicTest(IXFRDistTest): def checkFullZone(self, serial): global zones - + # FIXME: 90% duplication from _getRecordsForSerial zone = [] for i in dns.zone.from_text(zones[serial], relativize=False).iterate_rdatasets(): @@ -233,7 +239,25 @@ class IXFRDistBasicTest(IXFRDistTest): self.checkIXFR(2,3) self.checkIXFR(1,3) + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + sock.bind(("127.0.0.1", xfrServerPort + 1)) + sock.settimeout(2) + self.waitUntilCorrectSerialIsLoaded(serial=4, timeout=10, notify=True) + + # recv the forwarded NOTIFY + data, addr = sock.recvfrom(4096) + received = dns.message.from_wire(data) + sock.close() + + notif = dns.message.make_query('example.', 'SOA') + notif.set_opcode(dns.opcode.NOTIFY) + notif.flags |= dns.flags.AA + notif.flags &= ~dns.flags.RD + notif.id = received.id + + self.assertEqual(received, notif) + self.checkFullZone(4) self.checkIXFR(3,4) self.checkIXFR(2,4) diff --git a/regression-tests.ixfrdist/test_Stats.py b/regression-tests.ixfrdist/test_Stats.py index e3f6e7a848..1be5735c0d 100644 --- a/regression-tests.ixfrdist/test_Stats.py +++ b/regression-tests.ixfrdist/test_Stats.py @@ -27,7 +27,7 @@ failed-soa-retry: 3 webserver-address: %s """ - _config_domains = {'example': '127.0.0.1:' + str(xfrServerPort)} + _config_domains = [{'domain' : 'example', 'master' : '127.0.0.1:' + str(xfrServerPort)}] metric_prog_stats = ["ixfrdist_uptime_seconds", "ixfrdist_domains", "ixfrdist_unknown_domain_inqueries_total",