etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / bin / tests / system / addzone / tests.sh
blobc2e61673de4e605ed517b00c096680dd0d73cee4
1 #!/bin/sh
3 # Copyright (C) 2010-2013 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 # Id: tests.sh,v 1.6 2011/06/17 23:47:49 tbox Exp
19 SYSTEMTESTTOP=..
20 . $SYSTEMTESTTOP/conf.sh
22 DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300"
23 status=0
24 n=0
26 echo "I:checking normally loaded zone ($n)"
27 ret=0
28 $DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n || ret=1
29 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
30 grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
31 n=`expr $n + 1`
32 if [ $ret != 0 ]; then echo "I:failed"; fi
33 status=`expr $status + $ret`
35 echo "I:checking previously added zone ($n)"
36 ret=0
37 $DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n || ret=1
38 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
39 grep '^a.previous.example' dig.out.ns2.$n > /dev/null || ret=1
40 n=`expr $n + 1`
41 if [ $ret != 0 ]; then echo "I:failed"; fi
42 status=`expr $status + $ret`
44 echo "I:adding new zone ($n)"
45 ret=0
46 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
47 $DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n || ret=1
48 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
49 grep '^a.added.example' dig.out.ns2.$n > /dev/null || ret=1
50 n=`expr $n + 1`
51 if [ $ret != 0 ]; then echo "I:failed"; fi
52 status=`expr $status + $ret`
54 echo "I:adding a zone that requires quotes ($n)"
55 ret=0
56 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"32/1.0.0.127-in-addr.added.example" { check-names ignore; type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
57 $DIG $DIGOPTS @10.53.0.2 "a.32/1.0.0.127-in-addr.added.example" a > dig.out.ns2.$n || ret=1
58 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
59 grep '^a.32/1.0.0.127-in-addr.added.example' dig.out.ns2.$n > /dev/null || ret=1
60 n=`expr $n + 1`
61 if [ $ret != 0 ]; then echo "I:failed"; fi
62 status=`expr $status + $ret`
64 echo "I:adding a zone with a quote in the name ($n)"
65 ret=0
66 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"foo\"bar.example" { check-names ignore; type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
67 $DIG $DIGOPTS @10.53.0.2 "a.foo\"bar.example" a > dig.out.ns2.$n || ret=1
68 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
69 grep '^a.foo\\"bar.example' dig.out.ns2.$n > /dev/null || ret=1
70 n=`expr $n + 1`
71 if [ $ret != 0 ]; then echo "I:failed"; fi
72 status=`expr $status + $ret`
74 echo "I:adding new zone with missing master file ($n)"
75 ret=0
76 $DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.pre.$n || ret=1
77 grep "status: REFUSED" dig.out.ns2.pre.$n > /dev/null || ret=1
78 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'missing.example { type master; file "missing.db"; };' 2> rndc.out.ns2.$n
79 grep "file not found" rndc.out.ns2.$n > /dev/null || ret=1
80 $DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.post.$n || ret=1
81 grep "status: REFUSED" dig.out.ns2.post.$n > /dev/null || ret=1
82 $PERL ../digcomp.pl dig.out.ns2.pre.$n dig.out.ns2.post.$n || ret=1
83 n=`expr $n + 1`
84 if [ $ret != 0 ]; then echo "I:failed"; fi
85 status=`expr $status + $ret`
87 echo "I:verifying no comments in nzf file ($n)"
88 ret=0
89 hcount=`grep "^# New zone file for view: _default" ns2/3bf305731dd26307.nzf | wc -l`
90 [ $hcount -eq 0 ] || ret=1
91 n=`expr $n + 1`
92 if [ $ret != 0 ]; then echo "I:failed"; fi
93 status=`expr $status + $ret`
95 echo "I:deleting previously added zone ($n)"
96 ret=0
97 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /'
98 $DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n
99 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
100 grep '^a.previous.example' dig.out.ns2.$n > /dev/null && ret=1
101 n=`expr $n + 1`
102 if [ $ret != 0 ]; then echo "I:failed"; fi
103 status=`expr $status + $ret`
105 echo "I:checking nzf file now has comment ($n)"
106 ret=0
107 hcount=`grep "^# New zone file for view: _default" ns2/3bf305731dd26307.nzf | wc -l`
108 [ $hcount -eq 1 ] || ret=1
109 n=`expr $n + 1`
110 if [ $ret != 0 ]; then echo "I:failed"; fi
111 status=`expr $status + $ret`
113 echo "I:deleting newly added zone ($n)"
114 ret=0
115 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone added.example 2>&1 | sed 's/^/I:ns2 /'
116 $DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n
117 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
118 grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1
119 n=`expr $n + 1`
120 if [ $ret != 0 ]; then echo "I:failed"; fi
121 status=`expr $status + $ret`
123 echo "I:deleting newly added zone with escaped quote ($n)"
124 ret=0
125 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone "foo\\\"bar.example" 2>&1 | sed 's/^/I:ns2 /'
126 $DIG $DIGOPTS @10.53.0.2 "a.foo\"bar.example" a > dig.out.ns2.$n
127 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
128 grep "^a.foo\"bar.example" dig.out.ns2.$n > /dev/null && ret=1
129 n=`expr $n + 1`
130 if [ $ret != 0 ]; then echo "I:failed"; fi
131 status=`expr $status + $ret`
133 echo "I:attempt to delete a normally-loaded zone ($n)"
134 ret=0
135 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2> rndc.out.ns2.$n
136 grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
137 $DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n
138 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
139 grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
140 n=`expr $n + 1`
141 if [ $ret != 0 ]; then echo "I:failed"; fi
142 status=`expr $status + $ret`
144 echo "I:attempting to add master zone with inline signing ($n)"
145 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inline.example { type master; file "inline.db"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
146 for i in 1 2 3 4 5
148 ret=0
149 $DIG $DIGOPTS @10.53.0.2 a.inline.example a > dig.out.ns2.$n || ret=1
150 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
151 grep '^a.inline.example' dig.out.ns2.$n > /dev/null || ret=1
152 [ $ret = 0 ] && break
153 sleep 1
154 done
155 n=`expr $n + 1`
156 if [ $ret != 0 ]; then echo "I:failed"; fi
157 status=`expr $status + $ret`
159 echo "I:attempting to add master zone with inline signing and missing master ($n)"
160 ret=0
161 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlinemissing.example { type master; file "missing.db"; inline-signing yes; };' 2> rndc.out.ns2.$n
162 grep "file not found" rndc.out.ns2.$n > /dev/null || ret=1
163 n=`expr $n + 1`
164 if [ $ret != 0 ]; then echo "I:failed"; fi
165 status=`expr $status + $ret`
167 echo "I:attempting to add slave zone with inline signing ($n)"
168 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlineslave.example { type slave; masters { 10.53.0.1; }; file "inlineslave.bk"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
169 for i in 1 2 3 4 5
171 ret=0
172 $DIG $DIGOPTS @10.53.0.2 a.inlineslave.example a > dig.out.ns2.$n || ret=1
173 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
174 grep '^a.inlineslave.example' dig.out.ns2.$n > /dev/null || ret=1
175 [ $ret = 0 ] && break
176 sleep 1
177 done
178 n=`expr $n + 1`
179 if [ $ret != 0 ]; then echo "I:failed"; fi
180 status=`expr $status + $ret`
182 echo "I:attempting to delete slave zone with inline signing ($n)"
183 ret=0
184 for i in 0 1 2 3 4 5 6 7 8 9
186 test -f ns2/inlineslave.bk.signed -a -f ns2/inlineslave.bk && break
187 sleep 1
188 done
189 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone inlineslave.example 2>&1 > rndc.out2.test$n
190 test -f inlineslave.bk ||
191 grep '^inlineslave.bk$' rndc.out2.test$n > /dev/null || {
192 echo "I:failed to report inlineslave.bk"; ret=1;
194 test ! -f inlineslave.bk.signed ||
195 grep '^inlineslave.bk.signed$' rndc.out2.test$n > /dev/null || {
196 echo "I:failed to report inlineslave.bk.signed"; ret=1;
198 n=`expr $n + 1`
199 status=`expr $status + $ret`
201 echo "I:restoring slave zone with inline signing ($n)"
202 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlineslave.example { type slave; masters { 10.53.0.1; }; file "inlineslave.bk"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
203 for i in 1 2 3 4 5
205 ret=0
206 $DIG $DIGOPTS @10.53.0.2 a.inlineslave.example a > dig.out.ns2.$n || ret=1
207 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
208 grep '^a.inlineslave.example' dig.out.ns2.$n > /dev/null || ret=1
209 [ $ret = 0 ] && break
210 sleep 1
211 done
212 n=`expr $n + 1`
213 if [ $ret != 0 ]; then echo "I:failed"; fi
214 status=`expr $status + $ret`
216 echo "I:deleting slave zone with automatic zone file removal ($n)"
217 ret=0
218 for i in 0 1 2 3 4 5 6 7 8 9
220 test -f ns2/inlineslave.bk.signed -a -f ns2/inlineslave.bk && break
221 sleep 1
222 done
223 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone -clean inlineslave.example 2>&1 > /dev/null
224 for i in 0 1 2 3 4 5 6 7 8 9
226 ret=0
227 test -f ns2/inlineslave.bk.signed -a -f ns2/inlineslave.bk && ret=1
228 [ $ret = 0 ] && break
229 sleep 1
230 done
231 n=`expr $n + 1`
232 status=`expr $status + $ret`
234 echo "I:reconfiguring server with multiple views"
235 rm -f ns2/named.conf
236 cp -f ns2/named2.conf ns2/named.conf
237 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /'
238 sleep 5
240 echo "I:adding new zone to external view ($n)"
241 # NOTE: The internal view has "recursion yes" set, and so queries for
242 # nonexistent zones should return NOERROR. The external view is
243 # "recursion no", so queries for nonexistent zones should return
244 # REFUSED. This behavior should be the same regardless of whether
245 # the zone does not exist because a) it has not yet been loaded, b)
246 # it failed to load, or c) it has been deleted.
247 ret=0
248 $DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.intpre.$n || ret=1
249 grep 'status: NOERROR' dig.out.ns2.intpre.$n > /dev/null || ret=1
250 $DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.extpre.$n || ret=1
251 grep 'status: REFUSED' dig.out.ns2.extpre.$n > /dev/null || ret=1
252 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in external { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
253 $DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1
254 grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1
255 $DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1
256 grep 'status: NOERROR' dig.out.ns2.ext.$n > /dev/null || ret=1
257 grep '^a.added.example' dig.out.ns2.ext.$n > /dev/null || ret=1
258 n=`expr $n + 1`
259 if [ $ret != 0 ]; then echo "I:failed"; fi
260 status=`expr $status + $ret`
262 echo "I:checking new nzf file has comment ($n)"
263 ret=0
264 hcount=`grep "^# New zone file for view: external" ns2/3c4623849a49a539.nzf | wc -l`
265 [ $hcount -eq 1 ] || ret=1
266 n=`expr $n + 1`
267 if [ $ret != 0 ]; then echo "I:failed"; fi
268 status=`expr $status + $ret`
271 echo "I:deleting newly added zone ($n)"
272 ret=0
273 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'added.example in external' 2>&1 | sed 's/^/I:ns2 /'
274 $DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.$n || ret=1
275 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
276 grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1
277 n=`expr $n + 1`
278 if [ $ret != 0 ]; then echo "I:failed"; fi
279 status=`expr $status + $ret`
281 echo "I:attempting to add zone to internal view ($n)"
282 ret=0
283 $DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.pre.$n || ret=1
284 grep 'status: NOERROR' dig.out.ns2.pre.$n > /dev/null || ret=1
285 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in internal { type master; file "added.db"; };' 2> rndc.out.ns2.$n
286 grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1
287 $DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1
288 grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1
289 $DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1
290 grep 'status: REFUSED' dig.out.ns2.ext.$n > /dev/null || ret=1
291 n=`expr $n + 1`
292 if [ $ret != 0 ]; then echo "I:failed"; fi
293 status=`expr $status + $ret`
295 echo "I:ensure the configuration context is cleaned up correctly ($n)"
296 ret=0
297 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig > /dev/null 2>&1 || ret=1
298 sleep 5
299 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 status > /dev/null 2>&1 || ret=1
300 n=`expr $n + 1`
301 if [ $ret != 0 ]; then echo "I:failed"; fi
302 status=`expr $status + $ret`
304 echo "I:exit status: $status"
305 exit $status