forked from bortzmeyer/dns-lg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.sh
executable file
·247 lines (218 loc) · 6.96 KB
/
tests.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
98
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
126
127
128
129
130
131
132
133
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#!/bin/sh
# -*- coding: utf-8 -*-
# Send many different requests to a DNS-LG. No automatic testing, you
# have to read the results and interpret them yourself.
# To test HTML output validity, one may try
# "curl -s ${URL}/${domain}\?format=HTML | xmllint --noout --dtdvalid /usr/share/xml/xhtml/schema/dtd/1.0/xhtml1-strict.dtd -"
URL=${DNSLG_URL:-'http://localhost:8080'}
WEB=${DNSLG_COMMAND:-'curl -s --write-out Return_code_%{http_code},_%{content_type},_%{size_download}_B,_%{time_total}_s\n\n'}
DELAY=${DNSLG_DELAY:-0}
# Other sites describing deliberately broken DNS zones:
# http://www.test-aaaa-block.cl/
# http://www.dnssec-tools.org/testzone/index.html
# http://tjeb.nl/Projects/DNSSEC/
# See also validator.py for tests of the WSGI compliance
# TODO: test with another base
delay() {
if [ $DELAY != 0 ]; then
sleep $DELAY
fi
}
unset http_proxy
echo Qname which exist, default qtype which exist
for domain in ietf.org gouvernement.fr; do
${WEB} ${URL}/${domain}
done
echo ""
echo Qname which exist, explicit qtype which exist
for domain in ietf.org gouvernement.fr; do
${WEB} ${URL}/${domain}/A
done
echo ""
echo Several answers
for domain in google.com facebook.com; do
${WEB} ${URL}/${domain}/A
done
echo ""
delay
echo Domain which does not exist
${WEB} ${URL}/doesnotexist.example
echo ""
echo Unknown type
${WEB} ${URL}/fr/XXXX
echo ""
delay
echo No data for this qtype
${WEB} ${URL}/fr/AAAA
${WEB} ${URL}/fr/SRV
${WEB} ${URL}/www.bortzmeyer.org/PTR
echo ""
delay
echo Existing qtypes, for different formats. ADDR is a pseudo-qtype.
for type in MX SOA NS DNSKEY AAAA ADDR; do
for domain in ietf.org nic.fr; do
for format in text zone xml html json; do
echo "${type} ${domain} (${format})"
${WEB} ${URL}/${domain}/${type}?format=${format}
echo ""
delay
done
done
done
delay
for type in LOC; do
# All AFNIC name servers have a LOC
for domain in dns.lyn2.nic.fr uclouvain.sri.ucl.ac.be; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
done
done
delay
for type in TXT; do
for domain in several-records.generic-nic.net several-strings.generic-nic.net ; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
done
done
for type in DS; do
for domain in bortzmeyer.fr isc.org; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
delay
done
done
for type in NSEC3PARAM; do
for domain in fr gov com; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
delay
done
done
for type in NAPTR; do
for domain in http.uri.arpa education.lu mailclub.tel; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
delay
done
done
delay
for type in SRV; do
for domain in _xmpp-client._tcp.dns-oarc.net _nicname._tcp.fr.; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
delay
done
done
for type in PTR; do
for domain in 2.58.22.12.in-addr.arpa e.1.0.0.1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.a.3.2.1.0.9.8.1.1.0.0.2.ip6.arpa; do
for format in text zone xml html json; do
${WEB} ${URL}/${domain}/${type}?format=${format}
done
delay
done
done
echo ""
delay
echo We should be able to query the root.
# TODO: But . is special in a URL and Apache modifies it (it works
# with the test server). Hence the pseudo-TLD root. The rest is not
# guaranteed to work.
for format in text zone xml html json; do
${WEB} ${URL}/root/SOA?format=${format}
${WEB} ${URL}/./SOA?format=${format}
${WEB} ${URL}?format=${format}
${WEB} ${URL}/?format=${format}
delay
done
echo Tests with CNAME and DNAME
for format in text zone xml html json; do
${WEB} ${URL}/alias-c.generic-nic.net/AAAA?format=${format}
${WEB} ${URL}/alias-c.generic-nic.net/CNAME?format=${format}
${WEB} ${URL}/alias-d.generic-nic.net/AAAA?format=${format}
${WEB} ${URL}/alias-d.generic-nic.net/DNAME?format=${format}
${WEB} ${URL}/www.testonly.sources.org/AAAA?format=${format}
${WEB} ${URL}/www.testonly.sources.org/DNAME?format=${format}
delay
done
echo ""
delay
echo Reverse queries
for format in text zone xml html json; do
${WEB} ${URL}/192.5.5.241?format=${format}\&reverse=1
${WEB} ${URL}/2001:500:2f::f?format=${format}\&reverse=1
done
echo ""
echo Alternative resolver
for format in text zone xml html json; do
# Google Public DNS, OARC's ODVR, Telecomix
for resolver in 8.8.8.8 149.20.64.21 91.191.136.152; do
${WEB} ${URL}/example.net/SOA?format=${format}\&server=${resolver}
done
done
echo ""
delay
echo Existing classes
${WEB} ${URL}/fr/SOA/IN
# Will fail, since the name servers do not serve this class
${WEB} ${URL}/fr/SOA/CH
echo ""
delay
echo Unknown class
${WEB} ${URL}/fr/SOA/XX
echo ""
delay
echo IDN
# Important to test all output formats since they have very different
# Unicode capabilities
for format in text zone xml html json; do
${WEB} ${URL}/latablée.fr/SOA?format=${format}
${WEB} ${URL}/latabl%C3%A9e.fr/SOA?format=${format}
# The next one have an IDN name server
${WEB} ${URL}/elzévir.fr/NS?format=${format}
done
echo ""
echo Options
for format in text zone xml html json; do
${WEB} ${URL}/afnic.fr/SOA?format=${format}\&dodnssec=1
${WEB} ${URL}/afnic.fr/SOA?format=${format}\&dodnssec=1\&cd=1
${WEB} ${URL}/afnic.fr/SOA?format=${format}\&tcp=1
${WEB} ${URL}/afnic.fr/SOA?format=${format}\&buffersize=0
${WEB} ${URL}/afnic.fr/SOA?format=${format}\&buffersize=512
delay
done
echo ""
delay
echo "Test with names and data with special characters (such as & to crash the XML output)"
${WEB} ${URL}/dangerousrecord.broken-on-purpose.generic-nic.net/MX?format=xml
${WEB} ${URL}/dangerousrecord.broken-on-purpose.generic-nic.net/MX?format=json
${WEB} ${URL}/dangerous\<name.broken-on-purpose.generic-nic.net/TXT?format=xml
${WEB} ${URL}/dangerous\<name.broken-on-purpose.generic-nic.net/TXT?format=html
${WEB} ${URL}/dangerous{name.broken-on-purpose.generic-nic.net/TXT?format=json
echo ""
echo "Test with broken domains (all NS unreachable, for instance)"
${WEB} ${URL}/lame.broken-on-purpose.generic-nic.net/SOA?format=text
${WEB} ${URL}/lame2.broken-on-purpose.generic-nic.net/SOA?format=text
echo ""
echo "Test with invalid (DNSSEC) domains"
for domain in www.dnssec-failed.org. reverseddates-A.test.dnssec-tools.org; do
${WEB} ${URL}/${domain}/A?format=text\&dodnssec=1
${WEB} ${URL}/${domain}/A?format=text\&dodnssec=1\&cd=1
done
delay
# Various HTTP tricks
# This one requires curl, to have custom headers
# See issue #28
for format in application/json application/xml text/plain application/x-unknown; do
${WEB} --header "Accept: $format" ${URL}/mime.org/SOA
done
delay
# This one requires curl, to have custom headers
echo "Test methods other than GET (should be refused)"
${WEB} --head ${URL}/example.org/A
${WEB} --data STUFF ${URL}/example.org/A