From ba06b513d10e67e1510aa5e73d25938edaef5ea2 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Fri, 9 Feb 2024 11:27:22 +0100 Subject: [PATCH] ixfrdist: add a simple test for outgoing notify --- regression-tests.ixfrdist/ixfrdisttests.py | 8 +++-- regression-tests.ixfrdist/test_IXFR.py | 34 ++++++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/regression-tests.ixfrdist/ixfrdisttests.py b/regression-tests.ixfrdist/ixfrdisttests.py index 03638a4eb965..851e59799cf8 100644 --- a/regression-tests.ixfrdist/ixfrdisttests.py +++ b/regression-tests.ixfrdist/ixfrdisttests.py @@ -46,9 +46,11 @@ def startIXFRDist(cls): 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 159d85d4fba1..dbc1dc906fc0 100644 --- a/regression-tests.ixfrdist/test_IXFR.py +++ b/regression-tests.ixfrdist/test_IXFR.py @@ -2,6 +2,7 @@ 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 @@ def get_current_serial(): 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 @@ def test_c_IXFR_multi(self): 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)