Vendor import of Unbound 1.12.0.
[freebsd.git] / testdata / doh_downstream.tdir / doh_downstream.test
1 # #-- doh_downstream.test --#
2 # source the master var file when it's there
3 [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
4 # use .tpkg.var.test for in test variable passing
5 [ -f .tpkg.var.test ] && source .tpkg.var.test
6
7 PRE="../.."
8 . ../common.sh
9 if grep "define HAVE_NGHTTP2 1" $PRE/config.h; then echo test enabled; else echo test skipped; exit 0; fi
10 get_make
11 (cd $PRE; $MAKE dohclient)
12
13
14 # this test query should just work (server is up)
15 echo "> query www1.example.net."
16 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN >outfile 2>&1
17 cat outfile
18 if test "$?" -ne 0; then
19         echo "exit status not OK"
20         echo "> cat logfiles"
21         cat outfile
22         cat fwd.log 
23         cat unbound.log
24         echo "Not OK"
25         exit 1
26 fi
27 if grep "www1.example.net" outfile | grep "1.2.3.1"; then
28         echo "content OK"
29 else
30         echo "result contents not OK"
31         echo "> cat logfiles"
32         cat outfile
33         cat fwd.log 
34         cat unbound.log
35         echo "result contents not OK"
36         exit 1
37 fi
38 echo "OK"
39
40 # multiple requests (from localdata)
41 echo "> query www1.example.net. www2.example.net. www3.example.net."
42 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www2.example.net A IN www3.example.net A IN >outfile 2>&1
43 cat outfile
44 if test "$?" -ne 0; then
45         echo "exit status not OK"
46         echo "> cat logfiles"
47         cat outfile
48         cat fwd.log 
49         cat unbound.log
50         echo "Not OK"
51         exit 1
52 fi
53 if grep "www1.example.net" outfile | grep "1.2.3.1"; then
54         echo "content OK"
55 else
56         echo "result contents not OK"
57         echo "> cat logfiles"
58         cat outfile
59         cat fwd.log 
60         cat unbound.log
61         echo "result contents not OK"
62         exit 1
63 fi
64 if grep "www2.example.net" outfile | grep "1.2.3.2"; then
65         echo "content OK"
66 else
67         echo "result contents not OK"
68         echo "> cat logfiles"
69         cat outfile
70         cat fwd.log 
71         cat unbound.log
72         echo "result contents not OK"
73         exit 1
74 fi
75 if grep "www3.example.net" outfile | grep "1.2.3.3"; then
76         echo "content OK"
77 else
78         echo "result contents not OK"
79         echo "> cat logfiles"
80         cat outfile
81         cat fwd.log 
82         cat unbound.log
83         echo "result contents not OK"
84         exit 1
85 fi
86
87 # out of order requests, the example.com elements take 2 seconds to wait.
88 echo ""
89 echo "> query www1.example.net. www.example.com. www2.example.net. www2.example.com. www3.example.net."
90 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www.example.com. A IN www2.example.net A IN www2.example.com. A IN www3.example.net A IN >outfile 2>&1
91 cat outfile
92 if test "$?" -ne 0; then
93         echo "exit status not OK"
94         echo "> cat logfiles"
95         cat outfile
96         cat fwd.log 
97         cat unbound.log
98         echo "Not OK"
99         exit 1
100 fi
101 if grep "www1.example.net" outfile | grep "1.2.3.1"; then
102         echo "content OK"
103 else
104         echo "result contents not OK"
105         echo "> cat logfiles"
106         cat outfile
107         cat fwd.log 
108         cat unbound.log
109         echo "result contents not OK"
110         exit 1
111 fi
112 if grep "www2.example.net" outfile | grep "1.2.3.2"; then
113         echo "content OK"
114 else
115         echo "result contents not OK"
116         echo "> cat logfiles"
117         cat outfile
118         cat fwd.log 
119         cat unbound.log
120         echo "result contents not OK"
121         exit 1
122 fi
123 if grep "www3.example.net" outfile | grep "1.2.3.3"; then
124         echo "content OK"
125 else
126         echo "result contents not OK"
127         echo "> cat logfiles"
128         cat outfile
129         cat fwd.log 
130         cat unbound.log
131         echo "result contents not OK"
132         exit 1
133 fi
134 if grep "www.example.com" outfile | grep "10.20.30.40"; then
135         echo "content OK"
136 else
137         echo "result contents not OK"
138         echo "> cat logfiles"
139         cat outfile
140         cat fwd.log 
141         cat unbound.log
142         echo "result contents not OK"
143         exit 1
144 fi
145 if grep "www2.example.com" outfile | grep "10.20.30.42"; then
146         echo "content OK"
147 else
148         echo "result contents not OK"
149         echo "> cat logfiles"
150         cat outfile
151         cat fwd.log 
152         cat unbound.log
153         echo "result contents not OK"
154         exit 1
155 fi
156
157 # out of order requests, the example.com elements take 2 seconds to wait.
158 # www.example.com present twice, answered twice.
159 echo ""
160 echo "> query www1.example.net. www.example.com. www2.example.net. www.example.com. www3.example.net."
161 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www.example.com. A IN www2.example.net A IN www.example.com. A IN www3.example.net A IN >outfile 2>&1
162 cat outfile
163 if test "$?" -ne 0; then
164         echo "exit status not OK"
165         echo "> cat logfiles"
166         cat outfile
167         cat fwd.log 
168         cat unbound.log
169         echo "Not OK"
170         exit 1
171 fi
172 if grep "www1.example.net" outfile | grep "1.2.3.1"; then
173         echo "content OK"
174 else
175         echo "result contents not OK"
176         echo "> cat logfiles"
177         cat outfile
178         cat fwd.log 
179         cat unbound.log
180         echo "result contents not OK"
181         exit 1
182 fi
183 if grep "www2.example.net" outfile | grep "1.2.3.2"; then
184         echo "content OK"
185 else
186         echo "result contents not OK"
187         echo "> cat logfiles"
188         cat outfile
189         cat fwd.log 
190         cat unbound.log
191         echo "result contents not OK"
192         exit 1
193 fi
194 if grep "www3.example.net" outfile | grep "1.2.3.3"; then
195         echo "content OK"
196 else
197         echo "result contents not OK"
198         echo "> cat logfiles"
199         cat outfile
200         cat fwd.log 
201         cat unbound.log
202         echo "result contents not OK"
203         exit 1
204 fi
205 if grep "www.example.com" outfile | grep "10.20.30.40"; then
206         echo "content OK"
207 else
208         echo "result contents not OK"
209         echo "> cat logfiles"
210         cat outfile
211         cat fwd.log 
212         cat unbound.log
213         echo "result contents not OK"
214         exit 1
215 fi
216
217 # out of order requests, the example.com elements take 2 seconds to wait.
218 # www3.example.com present twice, answered twice.
219 echo ""
220 echo "> query www1.example.net. www3.example.com. www2.example.net. www3.example.com. www3.example.net."
221 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN www3.example.com. A IN www2.example.net A IN www3.example.com. A IN www3.example.net A IN >outfile 2>&1
222 cat outfile
223 if test "$?" -ne 0; then
224         echo "exit status not OK"
225         echo "> cat logfiles"
226         cat outfile
227         cat fwd.log 
228         cat unbound.log
229         echo "Not OK"
230         exit 1
231 fi
232 if grep "www1.example.net" outfile | grep "1.2.3.1"; then
233         echo "content OK"
234 else
235         echo "result contents not OK"
236         echo "> cat logfiles"
237         cat outfile
238         cat fwd.log 
239         cat unbound.log
240         echo "result contents not OK"
241         exit 1
242 fi
243 if grep "www2.example.net" outfile | grep "1.2.3.2"; then
244         echo "content OK"
245 else
246         echo "result contents not OK"
247         echo "> cat logfiles"
248         cat outfile
249         cat fwd.log 
250         cat unbound.log
251         echo "result contents not OK"
252         exit 1
253 fi
254 if grep "www3.example.net" outfile | grep "1.2.3.3"; then
255         echo "content OK"
256 else
257         echo "result contents not OK"
258         echo "> cat logfiles"
259         cat outfile
260         cat fwd.log 
261         cat unbound.log
262         echo "result contents not OK"
263         exit 1
264 fi
265 if grep "www3.example.com" outfile | grep "10.20.30.43"; then
266         echo "content OK"
267 else
268         echo "result contents not OK"
269         echo "> cat logfiles"
270         cat outfile
271         cat fwd.log 
272         cat unbound.log
273         echo "result contents not OK"
274         exit 1
275 fi
276
277 echo ""
278 echo "> query www4.example.com. www3.example.net."
279 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www4.example.com. A IN www3.example.net A IN >outfile 2>&1
280 cat outfile
281 if test "$?" -ne 0; then
282         echo "exit status not OK"
283         echo "> cat logfiles"
284         cat outfile
285         cat fwd.log 
286         cat unbound.log
287         echo "Not OK"
288         exit 1
289 fi
290 if grep "www3.example.net" outfile | grep "1.2.3.3"; then
291         echo "content OK"
292 else
293         echo "result contents not OK"
294         echo "> cat logfiles"
295         cat outfile
296         cat fwd.log 
297         cat unbound.log
298         echo "result contents not OK"
299         exit 1
300 fi
301 if grep "www4.example.com" outfile | grep "10.20.30.44"; then
302         echo "content OK"
303 else
304         echo "result contents not OK"
305         echo "> cat logfiles"
306         cat outfile
307         cat fwd.log 
308         cat unbound.log
309         echo "result contents not OK"
310         exit 1
311 fi
312
313
314 echo ""
315 echo "> query a1.example.com. - a90.example.com."
316 $PRE/dohclient -s 127.0.0.1 -p $UNBOUND_PORT www6.example.com. A IN a1.a.example.com. A IN a2.a.example.com. A IN a3.a.example.com. A IN a4.a.example.com. A IN a5.a.example.com. A IN a6.a.example.com. A IN a7.a.example.com. A IN a8.a.example.com. A IN a9.a.example.com. A IN a10.a.example.com. A IN a11.a.example.com. A IN a12.a.example.com. A IN a13.a.example.com. A IN a14.a.example.com. A IN a15.a.example.com. A IN a16.a.example.com. A IN a17.a.example.com. A IN a18.a.example.com. A IN a19.a.example.com. A IN a20.a.example.com. A IN a21.a.example.com. A IN a22.a.example.com. A IN a23.a.example.com. A IN a24.a.example.com. A IN a25.a.example.com. A IN a26.a.example.com. A IN a27.a.example.com. A IN a28.a.example.com. A IN a29.a.example.com. A IN a30.a.example.com. A IN a31.a.example.com. A IN a32.a.example.com. A IN a33.a.example.com. A IN a34.a.example.com. A IN a35.a.example.com. A IN a36.a.example.com. A IN a37.a.example.com. A IN a38.a.example.com. A IN a39.a.example.com. A IN a40.a.example.com. A IN a41.a.example.com. A IN a42.a.example.com. A IN a43.a.example.com. A IN a44.a.example.com. A IN a45.a.example.com. A IN a46.a.example.com. A IN a47.a.example.com. A IN a48.a.example.com. A IN a49.a.example.com. A IN a50.a.example.com. A IN a51.a.example.com. A IN a52.a.example.com. A IN a53.a.example.com. A IN a54.a.example.com. A IN a55.a.example.com. A IN a56.a.example.com. A IN a57.a.example.com. A IN a58.a.example.com. A IN a59.a.example.com. A IN a60.a.example.com. A IN a61.a.example.com. A IN a62.a.example.com. A IN a63.a.example.com. A IN a64.a.example.com. A IN a65.a.example.com. A IN a66.a.example.com. A IN a67.a.example.com. A IN a68.a.example.com. A IN a69.a.example.com. A IN a70.a.example.com. A IN a71.a.example.com. A IN a72.a.example.com. A IN a73.a.example.com. A IN a74.a.example.com. A IN a75.a.example.com. A IN a76.a.example.com. A IN a77.a.example.com. A IN a78.a.example.com. A IN a79.a.example.com. A IN a80.a.example.com. A IN a81.a.example.com. A IN a82.a.example.com. A IN a83.a.example.com. A IN a84.a.example.com. A IN a85.a.example.com. A IN a86.a.example.com. A IN a87.a.example.com. A IN a88.a.example.com. A IN a89.a.example.com. A IN a90.a.example.com. A IN >outfile 2>&1
317 cat outfile
318 if test "$?" -ne 0; then
319         echo "exit status not OK"
320         echo "> cat logfiles"
321         cat outfile
322         cat fwd.log 
323         cat unbound.log
324         echo "Not OK"
325         exit 1
326 fi
327 num_ans=$(grep -B 3 "a.example.com.     IN      A" outfile | grep "rcode: NOERROR" | wc -l )
328 if test "$num_ans" -ne 90; then
329         echo "number of answers not OK"
330         echo "> cat logfiles"
331         cat outfile
332         cat fwd.log
333         cat unbound.log
334         echo "Not OK"
335         exit 1
336 fi
337
338 echo "OK"
339 exit 0