]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ixfrdist: add a simple test for outgoing notify
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 9 Feb 2024 10:27:22 +0000 (11:27 +0100)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 9 Feb 2024 12:51:06 +0000 (13:51 +0100)
regression-tests.ixfrdist/ixfrdisttests.py
regression-tests.ixfrdist/test_IXFR.py
regression-tests.ixfrdist/test_Stats.py

index 03638a4eb965fec210c46d32382261b4b17c23d7..851e59799cf84b51adb13c28d5dccf0160003650 100644 (file)
@@ -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']
 
index 159d85d4fba18c6a3484fbc54b30e3d21bf7459b..dbc1dc906fc0bf980bb84aa088b36aefd2c3b9ee 100644 (file)
@@ -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)
index e3f6e7a8483580f28ceda313cde33aad64154c86..1be5735c0de87c33abeef4d4a7002789723ca20e 100644 (file)
@@ -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",