3 # Copyright (C) 2009, 2010, 2012 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.7 2010/01/18 19:19:31 each Exp
20 .
$SYSTEMTESTTOP/conf.sh
22 # replace_data dname RR old_data new_data
26 echo I
:unexpected input
for replace_data
36 $NSUPDATE -d <<END>> nsupdate.out.test 2>&1 || _ret=1
38 update delete ${_dname} 30 ${_rr} ${_olddata}
39 update add ${_dname} 30 ${_rr} ${_newdata}
43 if [ $_ret != 0 ]; then
44 echo I
:failed to update the
test data
54 DIGOPTS
="+short +tcp -p 5300"
55 DIGOPTS_CD
="$DIGOPTS +cd"
59 expect
="10 mail.example."
60 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 hostile MX` || ret
=1
61 test "$ans" = "$expect" || ret
=1
62 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
63 status
=`expr $status + $ret`
65 echo I
:Checking that bogus additional is not returned with
+CD.
68 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 mail.example A` || ret
=1
69 test "$ans" = "$expect" || ret
=1
70 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
71 status
=`expr $status + $ret`
74 # Prime cache with pending additional records. These should not be promoted
77 echo "I:Priming cache (pending additional A and AAAA)"
79 expect
="10 mail.example.com."
80 ans
=`$DIG $DIGOPTS @10.53.0.4 example.com MX` || ret
=1
81 test "$ans" = "$expect" || ret
=1
82 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
83 status
=`expr $status + $ret`
85 echo "I:Replacing pending A"
87 replace_data
mail.example.com. A
192.0.2.2 192.0.2.3 || ret
=1
88 status
=`expr $status + $ret`
90 echo "I:Replacing pending AAAA"
92 replace_data
mail.example.com. AAAA
2001:db8
::2 2001:db8
::3 || ret
=1
93 status
=`expr $status + $ret`
95 echo "I:Checking updated data to be returned (without CD)"
98 ans
=`$DIG $DIGOPTS @10.53.0.4 mail.example.com A` || ret
=1
99 test "$ans" = "$expect" || ret
=1
100 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
101 status
=`expr $status + $ret`
103 echo "I:Checking updated data to be returned (with CD)"
106 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 mail.example.com AAAA` || ret
=1
107 test "$ans" = "$expect" || ret
=1
108 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
109 status
=`expr $status + $ret`
112 # Prime cache with a pending answer record. It can be returned (without
113 # validation) with +CD.
115 echo "I:Priming cache (pending answer)"
118 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 pending-ok.example.com A` || ret
=1
119 test "$ans" = "$expect" || ret
=1
120 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
121 status
=`expr $status + $ret`
123 echo I
:Replacing pending data
125 replace_data pending-ok.example.com. A
192.0.2.2 192.0.2.3 || ret
=1
126 status
=`expr $status + $ret`
128 echo I
:Confirming cached pending data to be returned with CD
131 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 pending-ok.example.com A` || ret
=1
132 test "$ans" = "$expect" || ret
=1
133 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
134 status
=`expr $status + $ret`
137 # Prime cache with a pending answer record. It should not be returned
138 # to no-DNSSEC clients.
140 echo "I:Priming cache (pending answer)"
143 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 pending-ng.example.com A` || ret
=1
144 test "$ans" = "$expect" || ret
=1
145 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
146 status
=`expr $status + $ret`
148 echo I
:Replacing pending data
150 replace_data pending-ng.example.com. A
192.0.2.102 192.0.2.103 || ret
=1
151 status
=`expr $status + $ret`
153 echo I
:Confirming updated data returned
, not the cached one
, without CD
156 ans
=`$DIG $DIGOPTS @10.53.0.4 pending-ng.example.com A` || ret
=1
157 test "$ans" = "$expect" || ret
=1
158 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
159 status
=`expr $status + $ret`
162 # Try to fool the resolver with an out-of-bailiwick CNAME
164 echo I
:Trying to Prime out-of-bailiwick pending answer with CD
167 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 bad.example. A` || ret
=1
168 ans
=`echo $ans | awk '{print $NF}'`
169 test "$ans" = "$expect" || ret
=1
170 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
171 status
=`expr $status + $ret`
173 echo I
:Confirming the out-of-bailiwick answer is not cached or reused with CD
176 ans
=`$DIG $DIGOPTS_CD @10.53.0.4 nice.good. A` || ret
=1
177 ans
=`echo $ans | awk '{print $NF}'`
178 test "$ans" = "$expect" || ret
=1
179 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
180 status
=`expr $status + $ret`
183 # Make sure the resolver doesn't cache bogus NXDOMAIN
185 echo I
:Trying to Prime bogus NXDOMAIN
188 ans
=`$DIG +tcp -p 5300 @10.53.0.4 removed.example.com. A` || ret
=1
189 ans
=`echo $ans | sed 's/^.*status: \([A-Z][A-Z]*\).*$/\1/'`
190 test "$ans" = "$expect" || ret
=1
191 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
192 status
=`expr $status + $ret`
194 echo I
:Confirming the bogus NXDOMAIN was not cached
197 ans
=`$DIG +tcp -p 5300 @10.53.0.4 removed.example.com. A` || ret
=1
198 ans
=`echo $ans | sed 's/^.*status: \([A-Z][A-Z]*\).*$/\1/'`
199 test "$ans" = "$expect" || ret
=1
200 test $ret = 0 ||
echo I
:failed
, got
"'""$ans""'", expected
"'""$expect""'"
201 status
=`expr $status + $ret`
203 echo "I:exit status: $status"