Skip to content
Snippets Groups Projects
Commit 43dcb9f5 authored by Marek Vavruša's avatar Marek Vavruša
Browse files

tests-extra: functional tests for 'synth_record' query module

parent d47b3a8a
No related branches found
No related tags found
No related merge requests found
$ORIGIN 1.168.192.in-addr.arpa.
$TTL 172800 ; 2 days
@ IN SOA localhost root. (
43 ; serial
7200 ; refresh (2 hours)
300 ; retry (5 minutes)
2419200 ; expire (4 weeks)
10800 ; minimum (3 hours)
)
NS localhost
; Two static records
42 IN PTR static4-a.forward.
43 IN PTR static4-b.forward.
$ORIGIN 1.6.b.0.0.0.0.0.0.2.6.2.ip6.arpa.
$TTL 172800 ; 2 days
@ IN SOA localhost root. (
43 ; serial
7200 ; refresh (2 hours)
300 ; retry (5 minutes)
2419200 ; expire (4 weeks)
10800 ; minimum (3 hours)
)
NS localhost
; Two static hostnames
2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR static6-a.forward.
3.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0 IN PTR static6-b.forward.
$ORIGIN forward.
$TTL 3600
@ SOA dns1 hostmaster 2010111213 10800 3600 1209600 7200
NS dns1
NS dns2
dns1 A 192.0.2.1
AAAA 2001:DB8::1
dns2 A 192.0.2.2
AAAA 2001:DB8::2
; Two static record for each type
static4-a IN A 192.168.1.42
static4-b IN A 192.168.1.43
static6-a IN AAAA 2620:0:b61::42
static6-b IN AAAA 2620:0:b61::43
; Two aliases
cname4 IN CNAME dynamic4-192-168-1-1
cname6 IN CNAME dynamic6-2620-0000-0b61-0000-0000-0000-0000-0001
#!/usr/bin/env python3
''' Check 'synth_record' query module synthetic responses. '''
from dnstest.test import Test
t = Test()
# Zone indexes
FWD = 0
REV4 = 1
REV6 = 2
# Initialize server configuration
knot = t.server("knot")
zone = t.zone("forward.", storage=".") + \
t.zone("1.168.192.in-addr.arpa.", storage=".") + \
t.zone("1.6.b.0.0.0.0.0.0.2.6.2.ip6.arpa.", storage=".")
t.link(zone, knot)
# Configure 'synth_record' modules for auto forward/reverse zones
knot.add_query_module(zone[FWD], "synth_record", "forward dynamic4- 900 192.168.1.0/25")
knot.add_query_module(zone[FWD], "synth_record", "forward dynamic6- 900 2620:0:b61::/52")
knot.add_query_module(zone[REV4], "synth_record", "reverse dynamic4- forward. 900 192.168.1.0/25")
knot.add_query_module(zone[REV6], "synth_record", "reverse dynamic6- forward. 900 2620:0:b61::/52")
t.start()
# Static address mapping
static_map = [ ("192.168.1.42", "42." + zone[REV4].name, "static4-a.forward."),
("2620:0:b61::42", "2.4.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." + zone[REV6].name, "static6-a.forward.") ]
# Check static reverse records
for (_, reverse, forward) in static_map:
resp = knot.dig(reverse, "PTR")
resp.check(forward, rcode="NOERROR", flags="QR AA")
# Check static forward records
for (addr, reverse, forward) in static_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype)
resp.check(addr, rcode="NOERROR", flags="QR AA")
# Check positive dynamic reverse records
dynamic_map = [ ("192.168.1.1", "1." + zone[REV4].name, "dynamic4-192-168-1-1." + zone[FWD].name),
("2620:0:b61::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." + zone[REV6].name, "dynamic6-2620-0000-0b61-0000-0000-0000-0000-0001." + zone[FWD].name) ]
for (_, reverse, forward) in dynamic_map:
resp = knot.dig(reverse, "PTR")
resp.check(forward, rcode="NOERROR", flags="QR AA")
# Check positive dynamic forward records
for (addr, reverse, forward) in dynamic_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype)
resp.check(addr, rcode="NOERROR", flags="QR AA")
# Check NODATA answer for all records
for (addr, reverse, forward) in dynamic_map:
resp = knot.dig(reverse, "TXT")
resp.check(nordata=forward, rcode="NOERROR", flags="QR AA")
resp = knot.dig(forward, "TXT")
resp.check(nordata=addr, rcode="NOERROR", flags="QR AA")
# Check "out of subnet range" query response
nxdomain_map = [ ("192.168.1.128", "128." + zone[REV4].name, "dynamic4-192-168-1-128." + zone[FWD].name),
("2620:0:b61:1000::", "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.1." + zone[REV6].name, "dynamic6-2620-0000-0b61-1000-0000-0000-0000-0000." + zone[FWD].name) ]
for (addr, reverse, forward) in nxdomain_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(reverse, "PTR")
resp.check(rcode="NXDOMAIN", flags="QR AA")
resp = knot.dig(forward, rrtype)
resp.check(rcode="NXDOMAIN", flags="QR AA")
# Check alias leading to synthetic name
alias_map = [ ("192.168.1.1", None, "cname4." + zone[FWD].name),
("2620:0:b61::1", None, "cname6." + zone[FWD].name) ]
for (addr, _, forward) in alias_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype)
resp.check(addr, rcode="NOERROR", flags="QR AA")
# Check ANY type question
for (addr, reverse, forward) in dynamic_map:
resp = knot.dig(forward, "ANY")
resp.check(rcode="NOERROR", flags="QR AA")
t.end()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment