#!/usr/bin/env python3 '''Test of freeze-thaw feature''' from dnstest.test import Test from dnstest.utils import * t = Test(tsig=False) master = t.server("knot") zone = t.zone_rnd(1, records=300, dnssec=False) t.link(zone, master) master.dnssec(zone[0]).enable = True def soa_rrsig(server, zones): resp = server.dig(zones[0].name, "SOA", dnssec=True) return resp.resp.answer[1].to_rdataset()[0].to_text() master.ctl_params_append = ["-t", "35"] t.start() master.zone_wait(zone) rrsig0 = soa_rrsig(master, zone) master.ctl("zone-sign") # non-blocking
check_log("ZONE SOA TIMERS: REFRESH = 1, RETRY = 20, EXPIRE = 10") master.update_zonefile(zone, version=2) init_servers(master, slave) test_run_case(t, master, slave, action) def reload_server(t, s): s.reload() t.sleep(1) def restart_server(t, s): s.stop() s.start() t = Test() zone = t.zone("example.", storage=".") servers = create_servers(t, 2, zone) t.start() check_log("/// ACTION RELOAD ///") test_run(t, servers[0], zone, reload_server) check_log("/// ACTION RESTART ///") test_run(t, servers[1], zone, restart_server) t.stop()
if value == -1: isset(idx not in stats.get(section).get(item), idx) return else: data = int(stats.get(section).get(item).get(idx)) else: data = int(stats.get(section).get(item)) compare(data, value, "%s.%s" % (section, item)) ModStats.check() proto = random.choice([4, 6]) t = Test(stress=False, tsig=False, address=proto) knot = t.server("knot") zones = t.zone_rnd(2) t.link(zones, knot) knot.add_module(None, ModStats()) knot.add_module(zones[0], ModStats()) knot.add_module(zones[1], ModStats()) t.start() t.sleep(4) check_item(knot, "server", "zone-count", 2)
'''RRL module functionality test''' import dns.exception import dns.message import dns.query import os import time from dnstest.libknot import libknot from dnstest.test import Test from dnstest.module import ModRRL from dnstest.utils import * ctl = libknot.control.KnotCtl() t = Test(stress=False) ModRRL.check() knot = t.server("knot") zones = t.zone_rnd(2, dnssec=False, records=1) t.link(zones, knot) def send_queries(server, name, run_time=1.0, query_time=0.05): """ Send UDP queries to the server for certain time and get replies statistics. """ replied, slipped, dropped = 0, 0, 0 start = time.time() while time.time() < start + run_time:
#!/usr/bin/env python3 from dnstest.test import Test t = Test(tsig=True, stress=False) knot = t.server("knot") zone = t.zone("example.com") t.link(zone, knot, ddns=True) t.start() zone[0].name = "examPle.com" update = knot.update(zone) update.add("kNoT.ExamPle.com.", 60, "TXT", "test") update.add("test.example.com.", 60, "TXT", "test") update.send("NOERROR") resp = knot.dig("knot.example.com.", "TXT") resp.check(rcode="NOERROR", rdata="test") t.end()
from subprocess import check_call from dnstest.utils import * from dnstest.test import Test from dnstest.params import get_binary # Find PROTOS binaries protos_bin = [ "c09-dns-query-r1.jar", "c09-dns-zonetransfer-r1.jar" ] protos_java_bin = get_binary("PROTOS_JAVA_BIN", "java") protos_query_bin = get_binary("PROTOS_QUERY_BIN", protos_bin[0]) protos_zonetransfer_bin = get_binary("PROTOS_ZONETRANSFER_BIN", protos_bin[1]) if not protos_java_bin: raise Skip("Java not found") if not protos_query_bin: raise Skip("'%s' PROTOS binary not found" % protos_bin[0]) t = Test(address=4, tsig=False) # PROTOS works on IPv4, no TSIG master = t.server("dummy") slave = t.server("knot") zone = t.zone("protos.invalid.", exists=False) t.link(zone, master, slave) # Update configuration t.start() ''' Run PROTOS test case with given parameters. ''' def protos_run(name, binfile, params): if not binfile: return check_call([protos_java_bin, "-jar", binfile] + params, stdout=open(master.fout, mode="w"), stderr=open(master.ferr, mode="w")) shutil.move(master.fout, master.fout + "." + name)
'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW' ] t = Test(address=4, stress=False) knot = t.server("knot") zone = t.zone("example.com.", storage=".") t.link(zone, knot) # Generate configuration files for geoip module. geodb_filename = knot.dir + "geo.conf" subnet_filename = knot.dir + "net.conf" geo_conf = open(geodb_filename, "w") net_conf = open(subnet_filename, "w") dname_count = 10 iso_count = len(iso_codes) for i in range(1, dname_count + 1): print("d" + str(i) + ".example.com:", file=geo_conf) print("d" + str(i) + ".example.com:", file=net_conf)
#!/usr/bin/env python3 '''Test for the queryacl module''' from dnstest.utils import * from dnstest.test import Test from dnstest.module import ModQueryacl import random t = Test(address=4) knot = t.server("knot") zones = t.zone_rnd(3) t.link(zones, knot) knot.addr_extra = ["127.0.0.2", "127.0.0.3"] knot.add_module(zones[0], ModQueryacl(address=["127.0.0.1/32", "127.0.0.2/32"])) knot.add_module(zones[1], ModQueryacl(interface=["127.0.0.1/32", "127.0.0.2/32"])) knot.add_module( zones[2], ModQueryacl(address=["127.0.0.1/32", "127.0.0.2/32"], interface=["127.0.0.1/32", "127.0.0.2/32"])) t.start() knot.zones_wait(zones) # Test just address ACL.
#!/usr/bin/env python3 '''Test for EDNS0 UDP payload size limiting on the client side''' from dnstest.test import Test import dnstest.keys key = dnstest.keys.Tsig(name="key", alg="hmac-sha1", key="dmVyeWxvbmdrZXk=") t = Test(tsig=key) knot = t.server("knot") bind = t.server("bind") zone = t.zone("flags.") t.link(zone, knot) t.link(zone, bind) t.start() # TC - TXT record doesn't fit into UDP message (no TSIG). resp = knot.dig("513resp.flags", "TXT", udp=True, tsig=False) resp.check(flags="TC") resp.cmp(bind, additional=True) # no TC - UDP message is extended using EDNS0/payload (no TSIG). resp = knot.dig("513resp.flags", "TXT", udp=True, bufsize=524, tsig=False) resp.check(noflags="TC") resp.cmp(bind, additional=True) # TC - UDP message is extended using EDNS0/payload (with TSIG). resp = knot.dig("513resp.flags", "TXT", udp=True, bufsize=524 + 61, tsig=key)