1# #-- doh_downstream_notls.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
7PRE="../.."
8. ../common.sh
9get_make
10(cd $PRE; $MAKE dohclient)
11
12
13# this test query should just work (server is up)
14echo "> query www1.example.net."
15$PRE/dohclient -n -s 127.0.0.1 -p $UNBOUND_PORT www1.example.net. A IN >outfile 2>&1
16cat outfile
17if test "$?" -ne 0; then
18	echo "exit status not OK"
19	echo "> cat logfiles"
20	cat outfile
21	cat fwd.log 
22	cat unbound.log
23	echo "Not OK"
24	exit 1
25fi
26if grep "www1.example.net" outfile | grep "1.2.3.1"; then
27	echo "content OK"
28else
29	echo "result contents not OK"
30	echo "> cat logfiles"
31	cat outfile
32	cat fwd.log 
33	cat unbound.log
34	echo "result contents not OK"
35	exit 1
36fi
37echo "OK"
38
39# multiple requests (from localdata)
40echo "> query www1.example.net. www2.example.net. www3.example.net."
41$PRE/dohclient -n -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
42cat outfile
43if test "$?" -ne 0; then
44	echo "exit status not OK"
45	echo "> cat logfiles"
46	cat outfile
47	cat fwd.log 
48	cat unbound.log
49	echo "Not OK"
50	exit 1
51fi
52if grep "www1.example.net" outfile | grep "1.2.3.1"; then
53	echo "content OK"
54else
55	echo "result contents not OK"
56	echo "> cat logfiles"
57	cat outfile
58	cat fwd.log 
59	cat unbound.log
60	echo "result contents not OK"
61	exit 1
62fi
63if grep "www2.example.net" outfile | grep "1.2.3.2"; then
64	echo "content OK"
65else
66	echo "result contents not OK"
67	echo "> cat logfiles"
68	cat outfile
69	cat fwd.log 
70	cat unbound.log
71	echo "result contents not OK"
72	exit 1
73fi
74if grep "www3.example.net" outfile | grep "1.2.3.3"; then
75	echo "content OK"
76else
77	echo "result contents not OK"
78	echo "> cat logfiles"
79	cat outfile
80	cat fwd.log 
81	cat unbound.log
82	echo "result contents not OK"
83	exit 1
84fi
85
86# out of order requests, the example.com elements take 2 seconds to wait.
87echo ""
88echo "> query www1.example.net. www.example.com. www2.example.net. www2.example.com. www3.example.net."
89$PRE/dohclient -n -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
90cat outfile
91if test "$?" -ne 0; then
92	echo "exit status not OK"
93	echo "> cat logfiles"
94	cat outfile
95	cat fwd.log 
96	cat unbound.log
97	echo "Not OK"
98	exit 1
99fi
100if grep "www1.example.net" outfile | grep "1.2.3.1"; then
101	echo "content OK"
102else
103	echo "result contents not OK"
104	echo "> cat logfiles"
105	cat outfile
106	cat fwd.log 
107	cat unbound.log
108	echo "result contents not OK"
109	exit 1
110fi
111if grep "www2.example.net" outfile | grep "1.2.3.2"; then
112	echo "content OK"
113else
114	echo "result contents not OK"
115	echo "> cat logfiles"
116	cat outfile
117	cat fwd.log 
118	cat unbound.log
119	echo "result contents not OK"
120	exit 1
121fi
122if grep "www3.example.net" outfile | grep "1.2.3.3"; then
123	echo "content OK"
124else
125	echo "result contents not OK"
126	echo "> cat logfiles"
127	cat outfile
128	cat fwd.log 
129	cat unbound.log
130	echo "result contents not OK"
131	exit 1
132fi
133if grep "www.example.com" outfile | grep "10.20.30.40"; then
134	echo "content OK"
135else
136	echo "result contents not OK"
137	echo "> cat logfiles"
138	cat outfile
139	cat fwd.log 
140	cat unbound.log
141	echo "result contents not OK"
142	exit 1
143fi
144if grep "www2.example.com" outfile | grep "10.20.30.42"; then
145	echo "content OK"
146else
147	echo "result contents not OK"
148	echo "> cat logfiles"
149	cat outfile
150	cat fwd.log 
151	cat unbound.log
152	echo "result contents not OK"
153	exit 1
154fi
155
156# out of order requests, the example.com elements take 2 seconds to wait.
157# www.example.com present twice, answered twice.
158echo ""
159echo "> query www1.example.net. www.example.com. www2.example.net. www.example.com. www3.example.net."
160$PRE/dohclient -n -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
161cat outfile
162if test "$?" -ne 0; then
163	echo "exit status not OK"
164	echo "> cat logfiles"
165	cat outfile
166	cat fwd.log 
167	cat unbound.log
168	echo "Not OK"
169	exit 1
170fi
171if grep "www1.example.net" outfile | grep "1.2.3.1"; then
172	echo "content OK"
173else
174	echo "result contents not OK"
175	echo "> cat logfiles"
176	cat outfile
177	cat fwd.log 
178	cat unbound.log
179	echo "result contents not OK"
180	exit 1
181fi
182if grep "www2.example.net" outfile | grep "1.2.3.2"; then
183	echo "content OK"
184else
185	echo "result contents not OK"
186	echo "> cat logfiles"
187	cat outfile
188	cat fwd.log 
189	cat unbound.log
190	echo "result contents not OK"
191	exit 1
192fi
193if grep "www3.example.net" outfile | grep "1.2.3.3"; then
194	echo "content OK"
195else
196	echo "result contents not OK"
197	echo "> cat logfiles"
198	cat outfile
199	cat fwd.log 
200	cat unbound.log
201	echo "result contents not OK"
202	exit 1
203fi
204if grep "www.example.com" outfile | grep "10.20.30.40"; then
205	echo "content OK"
206else
207	echo "result contents not OK"
208	echo "> cat logfiles"
209	cat outfile
210	cat fwd.log 
211	cat unbound.log
212	echo "result contents not OK"
213	exit 1
214fi
215
216# out of order requests, the example.com elements take 2 seconds to wait.
217# www3.example.com present twice, answered twice.
218echo ""
219echo "> query www1.example.net. www3.example.com. www2.example.net. www3.example.com. www3.example.net."
220$PRE/dohclient -n -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
221cat outfile
222if test "$?" -ne 0; then
223	echo "exit status not OK"
224	echo "> cat logfiles"
225	cat outfile
226	cat fwd.log 
227	cat unbound.log
228	echo "Not OK"
229	exit 1
230fi
231if grep "www1.example.net" outfile | grep "1.2.3.1"; then
232	echo "content OK"
233else
234	echo "result contents not OK"
235	echo "> cat logfiles"
236	cat outfile
237	cat fwd.log 
238	cat unbound.log
239	echo "result contents not OK"
240	exit 1
241fi
242if grep "www2.example.net" outfile | grep "1.2.3.2"; then
243	echo "content OK"
244else
245	echo "result contents not OK"
246	echo "> cat logfiles"
247	cat outfile
248	cat fwd.log 
249	cat unbound.log
250	echo "result contents not OK"
251	exit 1
252fi
253if grep "www3.example.net" outfile | grep "1.2.3.3"; then
254	echo "content OK"
255else
256	echo "result contents not OK"
257	echo "> cat logfiles"
258	cat outfile
259	cat fwd.log 
260	cat unbound.log
261	echo "result contents not OK"
262	exit 1
263fi
264if grep "www3.example.com" outfile | grep "10.20.30.43"; then
265	echo "content OK"
266else
267	echo "result contents not OK"
268	echo "> cat logfiles"
269	cat outfile
270	cat fwd.log 
271	cat unbound.log
272	echo "result contents not OK"
273	exit 1
274fi
275
276echo ""
277echo "> query www4.example.com. www3.example.net."
278$PRE/dohclient -n -s 127.0.0.1 -p $UNBOUND_PORT www4.example.com. A IN www3.example.net A IN >outfile 2>&1
279cat outfile
280if test "$?" -ne 0; then
281	echo "exit status not OK"
282	echo "> cat logfiles"
283	cat outfile
284	cat fwd.log 
285	cat unbound.log
286	echo "Not OK"
287	exit 1
288fi
289if grep "www3.example.net" outfile | grep "1.2.3.3"; then
290	echo "content OK"
291else
292	echo "result contents not OK"
293	echo "> cat logfiles"
294	cat outfile
295	cat fwd.log 
296	cat unbound.log
297	echo "result contents not OK"
298	exit 1
299fi
300if grep "www4.example.com" outfile | grep "10.20.30.44"; then
301	echo "content OK"
302else
303	echo "result contents not OK"
304	echo "> cat logfiles"
305	cat outfile
306	cat fwd.log 
307	cat unbound.log
308	echo "result contents not OK"
309	exit 1
310fi
311
312
313echo ""
314echo "> query a1.example.com. - a90.example.com."
315$PRE/dohclient -n -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
316cat outfile
317if test "$?" -ne 0; then
318	echo "exit status not OK"
319	echo "> cat logfiles"
320	cat outfile
321	cat fwd.log 
322	cat unbound.log
323	echo "Not OK"
324	exit 1
325fi
326num_ans=$(grep -B 3 "a.example.com.	IN	A" outfile | grep "rcode: NOERROR" | wc -l )
327if test "$num_ans" -ne 90; then
328	echo "number of answers not OK"
329	echo "> cat logfiles"
330	cat outfile
331	cat fwd.log
332	cat unbound.log
333	echo "Not OK"
334	exit 1
335fi
336
337echo "OK"
338exit 0
339