test.py 4.44 KB
Newer Older
1 2 3 4
#!/usr/bin/env python3

''' For various query processing states. '''

5
from dnstest.test import Test
6

7
t = Test()
8
knot = t.server("knot")
9
knot.DIG_TIMEOUT = 2
10 11 12 13 14 15 16 17 18 19 20 21 22

bind = t.server("bind")
zone = t.zone("flags.")

t.link(zone, knot)
t.link(zone, bind)

t.start()

''' Negative answers. '''

# Negative (REFUSED)
resp = knot.dig("another.world", "SOA", udp=True)
23
resp.check(rcode="REFUSED")
24 25 26 27
resp.cmp(bind)

# Negative (NXDOMAIN)
resp = knot.dig("nxdomain.flags", "A", udp=True)
28
resp.check(rcode="NXDOMAIN")
29 30 31 32
resp.cmp(bind)

''' Positive answers. '''

33
# Positive (DATA)
34
resp = knot.dig("dns1.flags", "A", udp=True)
35 36 37
resp.check(rcode="NOERROR")
resp.cmp(bind)

38
# Positive (NODATA)
39
resp = knot.dig("dns1.flags", "TXT", udp=True)
40
resp.check(rcode="NOERROR")
41 42 43 44
resp.cmp(bind)

# Positive (REFERRAL)
resp = knot.dig("sub.flags", "NS", udp=True)
45
resp.check(rcode="NOERROR")
46 47 48 49
resp.cmp(bind)

# Positive (REFERRAL, below delegation)
resp = knot.dig("ns.sub.flags", "A", udp=True)
50
resp.check(rcode="NOERROR")
51 52 53 54
resp.cmp(bind)

''' ANY query type. '''

55
# ANY to SOA record
56 57 58
resp = knot.dig("flags", "ANY", udp=True)
resp.cmp(bind)

59
# ANY to A record
60 61 62
resp = knot.dig("dns1.flags", "ANY", udp=True)
resp.cmp(bind)

63
# ANY to delegation point
64 65 66
resp = knot.dig("sub.flags", "ANY", udp=True)
resp.cmp(bind)

67
# ANY to CNAME record
68 69 70
resp = knot.dig("cname.flags", "ANY", udp=True)
resp.cmp(bind)

71
# ANY to DNAME record
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
resp = knot.dig("dname.flags", "ANY", udp=True)
resp.cmp(bind)


''' CNAME answers. '''

# CNAME query
resp = knot.dig("cname.flags", "CNAME", udp=True)
resp.cmp(bind)

# CNAME leading to A
resp = knot.dig("cname.flags", "A", udp=True)
resp.cmp(bind)

# CNAME leading to A (NODATA)
resp = knot.dig("cname.flags", "TXT", udp=True)
resp.cmp(bind)

# CNAME leading to delegation
resp = knot.dig("cname-ns.flags", "NS", udp=True)
resp.cmp(bind)

# CNAME leading below delegation
resp = knot.dig("a.cname-ns.flags", "A", udp=True)
resp.cmp(bind)

98
# CNAME leading out
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
resp = knot.dig("cname-out.flags", "A", udp=True)
resp.cmp(bind)

''' DNAME answers. '''

# DNAME query
resp = knot.dig("dname.flags", "A", udp=True)
resp.cmp(bind)

# DNAME type query
resp = knot.dig("dname.flags", "DNAME", udp=True)
resp.cmp(bind)

# DNAME subtree query leading to A
resp = knot.dig("a.dname.flags", "A", udp=True)
resp.cmp(bind)

# DNAME subtree query leading to NODATA
resp = knot.dig("a.dname.flags", "TXT", udp=True)
resp.cmp(bind)

''' Wildcard answers. '''

# Wildcard query
resp = knot.dig("wildcard.flags", "A", udp=True)
resp.cmp(bind)

126
# Wildcard leading to A
127 128 129 130 131 132 133
resp = knot.dig("a.wildcard.flags", "A", udp=True)
resp.cmp(bind)

# Wildcard leading to A (NODATA)
resp = knot.dig("a.wildcard.flags", "TXT", udp=True)
resp.cmp(bind)

134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
# Deeper wildcard usage
resp = knot.dig("a.a.a.wildcard.flags", "A", udp=True)
resp.cmp(bind)

# Asterisk label
resp = knot.dig("sub.*.wildcard.flags", "A", udp=True)
resp.cmp(bind)

# Asterisk label (NODATA)
resp = knot.dig("sub.*.wildcard.flags", "TXT", udp=True)
resp.cmp(bind)

# Wildcard node under asterisk label
resp = knot.dig("*.*.wildcard.flags", "A", udp=True)
resp.cmp(bind)

# Wildcard node under asterisk label (NODATA)
resp = knot.dig("*.*.wildcard.flags", "TXT", udp=True)
resp.cmp(bind)

# Wildcard under asterisk label
resp = knot.dig("a.*.wildcard.flags", "A", udp=True)
resp.cmp(bind)

# Wildcard under asterisk label (NODATA)
resp = knot.dig("a.*.wildcard.flags", "TXT", udp=True)
resp.cmp(bind)

# Wildcard under DNAME subtree
163 164 165 166 167 168 169
resp = knot.dig("wildcard.dname.flags", "A", udp=True)
resp.cmp(bind)

# Wildcard under DNAME subtree (NODATA)
resp = knot.dig("wildcard.dname.flags", "TXT", udp=True)
resp.cmp(bind)

170
# Wildcard chain to A
171 172 173
resp = knot.dig("a.wildcard-cname.flags", "A", udp=True)
resp.cmp(bind)

174
# Wildcard chain to A (NODATA)
175 176 177
resp = knot.dig("a.wildcard-cname.flags", "TXT", udp=True)
resp.cmp(bind)

178
# Wildcard chain to NS
179 180 181 182 183 184 185
resp = knot.dig("a.wildcard-deleg.flags", "NS", udp=True)
resp.cmp(bind)

# Wildcard leading out
resp = knot.dig("a.wildcard-out.flags", "A", udp=True)
resp.cmp(bind)

186 187 188 189
# Wildcard leading to CNAME loop
resp = knot.dig("test.loop-entry.flags", "A", udp=True)
resp.cmp(bind)

190 191 192 193
''' Varied case tests. '''

# Negative (case preservation in question)
resp = knot.dig("ANOTHER.world", "SOA", udp=True)
194
resp.check(rcode="REFUSED")
195 196 197 198 199 200 201 202 203 204 205 206
resp.cmp(bind)

# Positive (varied name in zone) 
resp = knot.dig("dNS1.flags", "A", udp=True)
resp.check(rcode="NOERROR")
resp.cmp(bind)

# Positive (varied zone name)
resp = knot.dig("dns1.flAGs", "A", udp=True)
resp.check(rcode="NOERROR")
resp.cmp(bind)

207
t.end()