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
20 .
$SYSTEMTESTTOP/conf.sh
22 DIGOPTS
="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300"
26 echo "I:checking normally loaded zone ($n)"
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
32 if [ $ret != 0 ]; then echo "I:failed"; fi
33 status
=`expr $status + $ret`
35 echo "I:checking previously added zone ($n)"
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
41 if [ $ret != 0 ]; then echo "I:failed"; fi
42 status
=`expr $status + $ret`
44 echo "I:adding new zone ($n)"
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
51 if [ $ret != 0 ]; then echo "I:failed"; fi
52 status
=`expr $status + $ret`
54 echo "I:adding a zone that requires quotes ($n)"
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
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)"
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
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)"
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
84 if [ $ret != 0 ]; then echo "I:failed"; fi
85 status
=`expr $status + $ret`
87 echo "I:verifying no comments in nzf file ($n)"
89 hcount
=`grep "^# New zone file for view: _default" ns2/3bf305731dd26307.nzf | wc -l`
90 [ $hcount -eq 0 ] || ret
=1
92 if [ $ret != 0 ]; then echo "I:failed"; fi
93 status
=`expr $status + $ret`
95 echo "I:deleting previously added zone ($n)"
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
102 if [ $ret != 0 ]; then echo "I:failed"; fi
103 status
=`expr $status + $ret`
105 echo "I:checking nzf file now has comment ($n)"
107 hcount
=`grep "^# New zone file for view: _default" ns2/3bf305731dd26307.nzf | wc -l`
108 [ $hcount -eq 1 ] || ret
=1
110 if [ $ret != 0 ]; then echo "I:failed"; fi
111 status
=`expr $status + $ret`
113 echo "I:deleting newly added zone ($n)"
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
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)"
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
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)"
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
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 /'
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
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)"
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
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 /'
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
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)"
184 for i
in 0 1 2 3 4 5 6 7 8 9
186 test -f ns
2/inlineslave.bk.signed
-a -f ns
2/inlineslave.bk
&& break
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;
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 /'
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
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)"
218 for i
in 0 1 2 3 4 5 6 7 8 9
220 test -f ns
2/inlineslave.bk.signed
-a -f ns
2/inlineslave.bk
&& break
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
227 test -f ns
2/inlineslave.bk.signed
-a -f ns
2/inlineslave.bk
&& ret
=1
228 [ $ret = 0 ] && break
232 status
=`expr $status + $ret`
234 echo "I:reconfiguring server with multiple views"
236 cp -f ns
2/named2.conf ns
2/named.conf
237 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reconfig
2>&1 |
sed 's/^/I:ns2 /'
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.
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
259 if [ $ret != 0 ]; then echo "I:failed"; fi
260 status
=`expr $status + $ret`
262 echo "I:checking new nzf file has comment ($n)"
264 hcount
=`grep "^# New zone file for view: external" ns2/3c4623849a49a539.nzf | wc -l`
265 [ $hcount -eq 1 ] || ret
=1
267 if [ $ret != 0 ]; then echo "I:failed"; fi
268 status
=`expr $status + $ret`
271 echo "I:deleting newly added zone ($n)"
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
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)"
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
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)"
297 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reconfig
> /dev
/null
2>&1 || ret
=1
299 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 status
> /dev
/null
2>&1 || ret
=1
301 if [ $ret != 0 ]; then echo "I:failed"; fi
302 status
=`expr $status + $ret`
304 echo "I:exit status: $status"