etc/services - sync with NetBSD-8
[minix.git] / external / bsd / bind / dist / bin / tests / system / pending / tests.sh
blob08d1a45ad2fefac91eccf7990f7d599887bba9db
1 #!/bin/sh
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
19 SYSTEMTESTTOP=..
20 . $SYSTEMTESTTOP/conf.sh
22 # replace_data dname RR old_data new_data
23 replace_data()
25 if [ $# -ne 4 ]; then
26 echo I:unexpected input for replace_data
27 return 1
30 _dname=$1
31 _rr=$2
32 _olddata=$3
33 _newdata=$4
35 _ret=0
36 $NSUPDATE -d <<END>> nsupdate.out.test 2>&1 || _ret=1
37 server 10.53.0.2 5300
38 update delete ${_dname} 30 ${_rr} ${_olddata}
39 update add ${_dname} 30 ${_rr} ${_newdata}
40 send
41 END
43 if [ $_ret != 0 ]; then
44 echo I:failed to update the test data
45 return 1
48 return 0
51 status=0
52 n=0
54 DIGOPTS="+short +tcp -p 5300"
55 DIGOPTS_CD="$DIGOPTS +cd"
57 echo I:Priming cache.
58 ret=0
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.
66 ret=0
67 expect="10.0.0.2"
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
75 # to answer.
77 echo "I:Priming cache (pending additional A and AAAA)"
78 ret=0
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"
86 ret=0
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"
91 ret=0
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)"
96 ret=0
97 expect="192.0.2.3"
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)"
104 ret=0
105 expect="2001:db8::3"
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)"
116 ret=0
117 expect="192.0.2.2"
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
124 ret=0
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
129 ret=0
130 expect="192.0.2.2"
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)"
141 ret=0
142 expect="192.0.2.102"
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
149 ret=0
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
154 ret=0
155 expect="192.0.2.103"
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
165 ret=0
166 expect="10.10.10.10"
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
174 ret=0
175 expect="10.10.10.10"
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
186 ret=0
187 expect="SERVFAIL"
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
195 ret=0
196 expect="SERVFAIL"
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"
204 exit $status