knot-dns/tests-extra/tests/basic/flags/test.py

104 lines
2.7 KiB
Python
Raw Permalink Normal View History

2013-09-03 11:25:39 -04:00
#!/usr/bin/env python3
'''Test for header flags in response'''
2013-11-19 08:37:16 -05:00
from dnstest.test import Test
2013-09-03 11:25:39 -04:00
2013-11-19 08:37:16 -05:00
t = Test()
2013-09-03 11:25:39 -04:00
knot = t.server("knot")
2013-09-11 09:52:48 -04:00
bind = t.server("bind")
2013-09-03 11:25:39 -04:00
zone = t.zone("flags.")
t.link(zone, knot)
2013-09-11 09:52:48 -04:00
t.link(zone, bind)
2013-09-03 11:25:39 -04:00
t.start()
# RD flag preservation.
resp = knot.dig("flags", "NS", flags="RD")
resp.check(flags="QR AA RD", noflags="TC RA AD CD Z")
2013-09-11 09:52:48 -04:00
resp.cmp(bind)
2013-09-03 11:25:39 -04:00
2016-10-31 05:25:23 -04:00
# CD flag must be cleared (RFC 4035, Section 3.1.6).
resp = knot.dig("flags", "NS", flags="CD")
2016-10-31 05:25:23 -04:00
resp.check(flags="QR AA", noflags="TC RA AD RD CD Z")
# Bind preserves CD flag
# TC flag must be cleared
resp = knot.dig("flags", "NS", flags="TC")
resp.check(flags="QR AA", noflags="TC RA AD CD RD Z")
resp.cmp(bind)
# AD flag must be cleared
resp = knot.dig("flags", "NS", flags="AD")
resp.check(flags="QR AA", noflags="TC RA AD CD RD Z")
resp.cmp(bind)
# AA flag must be cleared
resp = knot.dig("sub.flags", "NS", flags="AA")
resp.check(flags="QR", noflags="AA TC RD RA AD CD Z")
resp.cmp(bind, additional=True)
# RA flag must be cleared
resp = knot.dig("flags", "NS", flags="RA")
resp.check(flags="QR AA", noflags="TC RA AD CD RD Z")
resp.cmp(bind)
# Z flag must be cleared
resp = knot.dig("flags", "NS", flags="Z")
resp.check(flags="QR AA", noflags="TC RA AD CD RD Z")
resp.cmp(bind)
# NULL record
resp = knot.dig("empty-null.flags.", "TYPE10")
resp.check(rcode="NOERROR", rdata="")
resp.cmp(bind)
2013-09-03 11:25:39 -04:00
# NS record for delegated subdomain (not authoritative).
resp = knot.dig("sub.flags", "NS")
resp.check(flags="QR", noflags="AA TC RD RA AD CD Z")
resp.cmp(bind, additional=True)
2013-09-03 11:25:39 -04:00
# Glue record for delegated subdomain (not authoritative).
resp = knot.dig("ns.sub.flags", "A")
resp.check(flags="QR", noflags="AA TC RD RA AD CD Z")
2013-09-11 09:52:48 -04:00
resp.cmp(bind)
# Wildcard DNAME
resp = knot.dig("a.b.wildcard-dname.flags", "A")
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
resp.cmp(bind)
# Wildcard DNAME "wildcard" query
resp = knot.dig("a.*.wildcard-dname.flags", "A")
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
resp.cmp(bind)
# Wildcard DNAME DNAME query
resp = knot.dig("a.wildcard-dname.flags", "DNAME")
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
resp.cmp(bind)
2013-09-11 09:52:48 -04:00
# Check maximal UDP payload which fits into a response message.
resp = knot.dig("512resp.flags", "TXT", udp=True)
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
resp.cmp(bind)
2013-09-03 11:25:39 -04:00
# TC bit - UDP.
2013-09-11 09:52:48 -04:00
resp = knot.dig("513resp.flags", "TXT", udp=True)
resp.check(flags="QR AA TC", noflags="RD RA AD CD Z")
resp.cmp(bind)
2013-09-03 11:25:39 -04:00
# No TC bit - TCP.
2013-09-11 09:52:48 -04:00
resp = knot.dig("513resp.flags", "TXT", udp=False)
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
2013-09-11 09:52:48 -04:00
resp.cmp(bind)
2013-09-03 11:25:39 -04:00
# Check ANY
resp = knot.dig("flags", "ANY")
resp.check(flags="QR AA", noflags="TC RD RA AD CD Z")
# nothing to compare
2013-10-11 03:40:45 -04:00
t.end()