1 # #-- 09-unbound-control.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
9 # exit value is 1 on usage
10 $PRE/unbound-control -h
11 if test $? -ne 1; then
12 echo "wrong exit value for usage."
15 echo "exit value for usage: OK"
18 # use lock-verify if possible
20 # test if the server is up.
21 echo "> dig www.example.com."
22 dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
24 if grep "10.20.30.40" outfile; then
34 # exit value is 1 when a bad command is given.
35 echo "$PRE/unbound-control -c ub.conf blablargh"
36 $PRE/unbound-control -c ub.conf blablargh
37 if test $? -ne 1; then
38 echo "wrong exit value on error."
44 echo "correct exit value on error"
47 # reload the server. test if the server came up by putting a new
48 # local-data element in the server.
49 echo "server: local-data: 'afterreload. IN A 5.6.7.8'" >> ub.conf
50 echo "$PRE/unbound-control -c ub.conf reload"
51 $PRE/unbound-control -c ub.conf reload
52 if test $? -ne 0; then
53 echo "wrong exit value after success"
57 echo "> dig afterreload."
58 dig @127.0.0.1 -p $UNBOUND_PORT afterreload. | tee outfile
60 if grep "5.6.7.8" outfile; then
70 # must have had queries now. 1 since reload.
71 echo "$PRE/unbound-control -c ub.conf stats"
72 $PRE/unbound-control -c ub.conf stats > tmp.$$
73 if test $? -ne 0; then
74 echo "wrong exit value after success"
77 if grep "^total.num.queries=[1-9][0-9]*$" tmp.$$; then
86 echo "$PRE/unbound-control -c ub.conf verbosity 2"
87 $PRE/unbound-control -c ub.conf verbosity 2
88 if test $? -ne 0; then
89 echo "wrong exit value after success"
93 # check syntax error in parse
94 echo "$PRE/unbound-control -c ub.conf verbosity jkdf"
95 $PRE/unbound-control -c ub.conf verbosity jkdf
96 if test $? -ne 1; then
97 echo "wrong exit value after failure"
101 # check bad credentials
103 echo "remote-control:" >> bad.conf
104 echo " server-key-file: bad_server.key" >> bad.conf
105 echo " server-cert-file: bad_server.pem" >> bad.conf
106 echo " control-key-file: bad_control.key" >> bad.conf
107 echo " control-cert-file: bad_control.pem" >> bad.conf
108 echo "$PRE/unbound-control -c bad.conf verbosity 2"
109 $PRE/unbound-control -c bad.conf verbosity 2
110 if test $? -ne 1; then
111 echo "wrong exit value after failure"
115 # check spoofedclient credentials
118 echo "remote-control:" >> bad.conf
119 echo " server-key-file: unbound_server.key" >> bad.conf
120 echo " server-cert-file: unbound_server.pem" >> bad.conf
121 echo " control-key-file: bad_control.key" >> bad.conf
122 echo " control-cert-file: bad_control.pem" >> bad.conf
123 echo "$PRE/unbound-control -c bad.conf verbosity 2"
124 $PRE/unbound-control -c bad.conf verbosity 2
125 if test $? -ne 1; then
126 echo "wrong exit value after failure"
130 # create a new local zone
131 echo "> test of local zone"
132 echo "$PRE/unbound-control -c ub.conf local_zone example.net static"
133 $PRE/unbound-control -c ub.conf local_zone example.net static
134 if test $? -ne 0; then
135 echo "wrong exit value after success"
138 echo "$PRE/unbound-control -c ub.conf local_data www.example.net A 192.0.2.1"
139 $PRE/unbound-control -c ub.conf local_data www.example.net A 192.0.2.1
140 if test $? -ne 0; then
141 echo "wrong exit value after success"
145 # check that www.example.net exists
146 echo "> dig www.example.net."
147 dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
148 echo "> check answer"
149 if grep "192.0.2.1" outfile; then
152 echo "> cat logfiles"
159 # check that mail.example.net has nxdomain
160 echo "> dig mail.example.net."
161 dig @127.0.0.1 -p $UNBOUND_PORT mail.example.net. | tee outfile
162 echo "> check answer"
163 if grep "NXDOMAIN" outfile; then
166 echo "> cat logfiles"
173 # remove www.example.net - check it gets nxdomain
174 echo "$PRE/unbound-control -c ub.conf local_data_remove www.example.net"
175 $PRE/unbound-control -c ub.conf local_data_remove www.example.net
176 if test $? -ne 0; then
177 echo "wrong exit value after success"
180 echo "> dig www.example.net."
181 dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
182 echo "> check answer"
183 if grep "NXDOMAIN" outfile; then
186 echo "> cat logfiles"
193 # remove nonexistent name - check bug#287(segfault) does not happen.
194 echo "$PRE/unbound-control -c ub.conf local_data_remove test.example.net"
195 $PRE/unbound-control -c ub.conf local_data_remove test.example.net
196 # if crash then then we get: error: could not SSL_read from unbound-control
197 if test $? -ne 0; then
198 echo "wrong exit value after success"
204 # remove example.net - check its gone.
205 echo "$PRE/unbound-control -c ub.conf local_zone_remove example.net"
206 $PRE/unbound-control -c ub.conf local_zone_remove example.net
207 if test $? -ne 0; then
208 echo "wrong exit value after success"
211 echo "> dig www.example.net."
212 dig @127.0.0.1 -p $UNBOUND_PORT www.example.net. | tee outfile
213 echo "> check answer"
214 if grep "SERVFAIL" outfile; then
217 echo "> cat logfiles"
225 echo "> test cache dump"
227 echo "dig www.example.com"
228 dig @127.0.0.1 -p $UNBOUND_PORT www.example.com.
229 echo "$PRE/unbound-control -c ub.conf dump_cache"
230 $PRE/unbound-control -c ub.conf dump_cache > tmp.$$
231 if test $? -ne 0; then
232 echo "wrong exit value after success"
236 if grep 10.20.30.40 tmp.$$; then
237 echo "OK example.com is in cache dump"
239 echo "Not OK cache dump"
244 echo "$PRE/unbound-control -c ub.conf lookup www.example.com"
245 $PRE/unbound-control -c ub.conf lookup www.example.com
246 if test $? -ne 0; then
247 echo "wrong exit value after success"
250 # answer to lookup is meaningless because of use a forwarder, oh well.
252 # load the cache dump.
253 echo "$PRE/unbound-control -c ub.conf load_cache < tmp.$$"
254 $PRE/unbound-control -c ub.conf load_cache < tmp.$$
255 if test $? -ne 0; then
256 echo "wrong exit value after success"
259 echo "> dig www.example.com."
260 dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile
261 echo "> check answer"
262 if grep "10.20.30.40" outfile; then
265 echo "> cat logfiles"
272 # load local-zones from file
273 echo "$PRE/unbound-control -c ub.conf local_zones < local_zones"
274 $PRE/unbound-control -c ub.conf local_zones < local_zones
275 if test $? -ne 0; then
276 echo "wrong exit value after success"
279 echo "> dig localzonefromfile."
280 dig @127.0.0.1 -p $UNBOUND_PORT localzonefromfile | tee outfile
281 echo "> check answer"
282 if grep "REFUSED" outfile; then
289 # load local-data from file
290 echo "$PRE/unbound-control -c ub.conf local_datas < local_data"
291 $PRE/unbound-control -c ub.conf local_datas < local_data
292 if test $? -ne 0; then
293 echo "wrong exit value after success"
296 echo "> dig localdatafromfile."
297 dig @127.0.0.1 -p $UNBOUND_PORT -t txt localdatafromfile | tee outfile
298 echo "> check answer"
299 if grep "local data from file OK" outfile; then
306 # remove local-zone and local-data from file
307 echo "$PRE/unbound-control -c ub.conf local_zones_remove < local_zones_remove"
308 $PRE/unbound-control -c ub.conf local_zones_remove < local_zones_remove
309 if test $? -ne 0; then
310 echo "wrong exit value after success"
313 echo "$PRE/unbound-control -c ub.conf local_datas_remove < local_data_remove"
314 $PRE/unbound-control -c ub.conf local_datas_remove < local_data_remove
315 if test $? -ne 0; then
316 echo "wrong exit value after success"
319 echo "> check zone and data removal list_local_zones"
320 $PRE/unbound-control -c ub.conf list_local_zones | tee outfile
321 if grep "localzonefromfile" outfile; then
325 if grep "local data from file OK" outfile; then
329 if grep "otherlocalzone" outfile; then
337 echo "$PRE/unbound-control -c ub.conf flush www.example.net"
338 $PRE/unbound-control -c ub.conf flush www.example.net
339 if test $? -ne 0; then
340 echo "wrong exit value after success"
344 echo "$PRE/unbound-control -c ub.conf flush_type www.example.net TXT"
345 $PRE/unbound-control -c ub.conf flush_type www.example.net TXT
346 if test $? -ne 0; then
347 echo "wrong exit value after success"
351 echo "$PRE/unbound-control -c ub.conf flush_zone example.net"
352 $PRE/unbound-control -c ub.conf flush_zone example.net
353 if test $? -ne 0; then
354 echo "wrong exit value after success"
358 # now stop the server
359 echo "$PRE/unbound-control -c ub.conf stop"
360 $PRE/unbound-control -c ub.conf stop
361 if test $? -ne 0; then
362 echo "wrong exit value after success"
365 # see if the server has really exited.
367 for (( try=0 ; try <= $TRY_MAX ; try++ )) ; do
368 if kill -0 $UNBOUND_PID 2>&1 | tee tmp.$$; then
369 echo "not stopped yet, waiting"
372 echo "stopped OK; break"
375 if grep "No such process" tmp.$$; then
376 echo "stopped OK; break"
380 if kill -0 $UNBOUND_PID; then
382 echo "> cat logfiles"
385 echo "not stopped, failure"
390 if test -f ublocktrace.0; then
391 if $PRE/lock-verify ublocktrace.*; then
392 echo "lock-verify test worked."
394 echo "lock-verify test failed."
402 echo "> cat logfiles"