Commit 5458c5b2 authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

tests: added test if signing is consistent

parent 8d28da69
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
#!/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()
......@@ -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):
......
......@@ -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.'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment