]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
tests: added test if signing is consistent
authorLibor Peltan <libor.peltan@nic.cz>
Fri, 18 Jan 2019 13:02:39 +0000 (14:02 +0100)
committerDaniel Salzman <daniel.salzman@nic.cz>
Tue, 22 Jan 2019 14:49:11 +0000 (15:49 +0100)
tests-extra/tests/dnssec/no_resign2/data/example.com.zone [new file with mode: 0644]
tests-extra/tests/dnssec/no_resign2/test.py [new file with mode: 0644]
tests-extra/tools/dnstest/server.py
tests-extra/tools/dnstest/zonefile.py

diff --git a/tests-extra/tests/dnssec/no_resign2/data/example.com.zone b/tests-extra/tests/dnssec/no_resign2/data/example.com.zone
new file mode 100644 (file)
index 0000000..d85d1c3
--- /dev/null
@@ -0,0 +1,11 @@
+example.com.           3       SOA     dns1.example.com. hostmaster.example.com. 2010111227 21600 3600 604800 3
+example.com.           0       NS      dns1.example.com.
+example.com.           2       MX      10 mail.example.com.
+dns1.example.com.      4       A       192.0.2.1
+dns1.example.com.      3       AAAA    2001:db8::1
+foo.example.com.       5       A       192.0.2.4
+mail.example.com.      3       A       192.0.2.3
+mail.example.com.      1       AAAA    2001:db8::3
+deleg.example.com.      6   NS  dns1.example.com.
+deleg2.ent.example.com. 7   NS  dns1.example.com.
+abcd.example.com.       9   A   192.0.3.4
diff --git a/tests-extra/tests/dnssec/no_resign2/test.py b/tests-extra/tests/dnssec/no_resign2/test.py
new file mode 100644 (file)
index 0000000..8273f6b
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/env python3
+
+'''Test for no re-signing if the zone is properly signed.'''
+
+from dnstest.utils import *
+from dnstest.test import Test
+
+t = Test()
+
+master = t.server("knot")
+
+zone = t.zone("example.com.", storage=".")
+
+t.link(zone, master, ixfr=True, journal_content="all")
+
+master.dnssec(zone).enable = True
+
+t.start()
+
+serial = master.zone_wait(zone)
+
+master.random_ddns(zone, allow_empty=False)
+
+serial = master.zone_wait(zone, serial)
+
+master.stop()
+t.sleep(1)
+master.start()
+
+new_serial = master.zone_wait(zone)
+
+if new_serial != serial:
+    set_err("zone got re-signed")
+
+t.stop()
index c4bff691dada635b6cf3a6c376e8de4317ead7c6..f7b28f3e375e8b69a782a18abcf279a1d5a84f3c 100644 (file)
@@ -717,11 +717,16 @@ class Server(object):
         else:
             self.zones[zone.name].zfile.upd_file(storage=storage, version=version)
 
-    def random_ddns(self, zone):
+    def random_ddns(self, zone, allow_empty=True):
         zone = zone_arg_check(zone)
 
         up = self.update(zone)
-        self.zones[zone.name].zfile.gen_rnd_ddns(up)
+
+        while True:
+            changes = self.zones[zone.name].zfile.gen_rnd_ddns(up)
+            if allow_empty or changes > 0:
+                break
+
         up.send("NOERROR")
 
     def add_module(self, zone, module):
index 3ddd8b56a8261812d5c5b4f65e6d2c3d5ac3a918..eb16010bd3526b1ffc29610e785a0127a0c003f1 100644 (file)
@@ -249,6 +249,7 @@ class ZoneFile(object):
     def gen_rnd_ddns(self, ddns):
         '''Walk zonefile, randomly mark some records to be removed by ddns and some added'''
 
+        changes = 0
         with open(self.path, 'r') as file:
             for fline in file:
                 line = fline.split(None, 3)
@@ -256,11 +257,14 @@ class ZoneFile(object):
                     try:
                         if random.randint(1, 20) in [4, 5]:
                             ddns.delete(line[0], line[2])
+                            changes += 1
                         if random.randint(1, 20) in [2, 3] and line[2] not in ["DNAME"]:
                             ddns.add("xyz."+line[0], line[1], line[2], line[3])
+                            changes += 1
                     except (dns.rdatatype.UnknownRdatatype, dns.name.LabelTooLong, dns.name.NameTooLong):
                         # problems - simply skip. This is completely stochastic anyway.
                         pass
+        return changes
 
     def remove(self):
         '''Remove zone file.'''