Skip to content

Commit

Permalink
ixfrdist: add a simple test for outgoing notify
Browse files Browse the repository at this point in the history
  • Loading branch information
chbruyand committed Feb 9, 2024
1 parent 801cb9a commit ba06b51
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
8 changes: 5 additions & 3 deletions regression-tests.ixfrdist/ixfrdisttests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']

Expand Down
34 changes: 29 additions & 5 deletions regression-tests.ixfrdist/test_IXFR.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import dns.serial
import time
import itertools
import socket

from ixfrdisttests import IXFRDistTest
from xfrserver.xfrserver import AXFRServer
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ba06b51

Please sign in to comment.