3 # Copyright (C) 2015 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.
18 .
$SYSTEMTESTTOP/conf.sh
23 # $1 = test name (such as 1a, 1b, etc. for which named.$1.conf exists)
27 echo "I:stopping resolver"
28 $PERL $SYSTEMTESTTOP/stop.pl . ns2
32 echo "I:starting resolver using named.$TESTNAME.conf"
33 cp -f ns
2/named.
$TESTNAME.conf ns
2/named.conf
34 $PERL $SYSTEMTESTTOP/start.pl
--noclean --restart . ns2
41 NAME
=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
42 $DIG $DIGOPTS $NAME a @
10.53.0.2 -p 5300 -b 127.0.0.1 > dig.out.
${t}
43 grep "status: SERVFAIL" dig.out.
${t} > /dev
/null
2>&1 && return 1
47 # $1 = test name (such as 1a, 1b, etc. for which $1.queries exists)
48 # $2 = line number in query file to test (the name to query is taken from this line)
53 NAME
=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
55 echo "I:testing $NAME doesn't recurse (${t})"
56 run_query
$TESTNAME $LINE ||
{
57 echo "I:test ${t} failed"
62 # $1 = test name (such as 1a, 1b, etc. for which $1.queries exists)
63 # $2 = line number in query file to test (the name to query is taken from this line)
68 NAME
=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
70 echo "I:testing $NAME recurses (${t})"
71 run_query
$TESTNAME $LINE && {
72 echo "I:test ${t} failed"
78 echo "I:testing that l1.l0 exists without RPZ (${t})"
79 $DIG $DIGOPTS l1.l0 ns @
10.53.0.2 -p 5300 > dig.out.
${t}
80 grep "status: NOERROR" dig.out.
${t} > /dev
/null
2>&1 ||
{
81 echo "I:test ${t} failed"
86 echo "I:testing that l2.l1.l0 returns SERVFAIL without RPZ (${t})"
87 $DIG $DIGOPTS l2.l1.l0 ns @
10.53.0.2 -p 5300 > dig.out.
${t}
88 grep "status: SERVFAIL" dig.out.
${t} > /dev
/null
2>&1 ||
{
89 echo "I:test ${t} failed"
100 expect_norecurse
1c
1
104 for n
in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
106 expect_norecurse
2a
$n
118 expect_norecurse
3d
1
121 expect_norecurse
3e
1
124 expect_norecurse
3f
1
130 # Uncomment the following to test every skip value instead of
131 # only a sample of values
133 #testlist="aa ab ac ad ae af ag ah ai aj ak al am an ao ap \
134 # aq ar as at au av aw ax ay az ba bb bc bd be bf"
135 #values="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
136 # 21 22 23 24 25 26 27 28 29 30 31 32"
138 for n
in $testlist; do
142 echo "I:testing that ${ni} of 33 queries skip recursion (${t})"
144 for i
in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \
145 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
150 skipped
=`expr 33 - $c`
151 if [ $skipped != $ni ]; then
152 echo "I:test $t failed (actual=$skipped, expected=$ni)"
160 expect_norecurse
5a
1
161 expect_norecurse
5a
2
168 echo "I:check recursive behavior consistency during policy update races"
172 echo "I:running dig to cache CNAME record (${t})"
173 $DIG $DIGOPTS @
10.53.0.2 -p 5300 www.
test.example.org CNAME
> dig.out.
${t}
175 echo "I:suspending authority server"
176 kill -TSTP `cat ns1/named.pid`
177 echo "I:adding an NSDNAME policy"
178 cp ns
2/db
.6a
.00.policy.
local ns
2/saved.policy.
local
179 cp ns
2/db
.6b
.00.policy.
local ns
2/db
.6a
.00.policy.
local
180 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reload
6a
.00.policy.
local 2>&1 |
sed 's/^/I:ns2 /'
183 echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})"
184 $DIG $DIGOPTS @
10.53.0.2 -p 5300 www.
test.example.org A
> dig.out.
${t} &
186 echo "I:removing the NSDNAME policy"
187 cp ns
2/db
.6c
.00.policy.
local ns
2/db
.6a
.00.policy.
local
188 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reload
6a
.00.policy.
local 2>&1 |
sed 's/^/I:ns2 /'
190 echo "I:resuming authority server"
191 kill -CONT `cat ns1/named.pid`
192 for n
in 1 2 3 4 5 6 7 8 9; do
194 [ -s dig.out.
${t} ] ||
continue
195 grep "status: NOERROR" dig.out.
${t} > /dev
/null
2>&1 ||
{
196 echo "I:test ${t} failed"
201 echo "I:check recursive behavior consistency during policy removal races"
202 cp ns
2/saved.policy.
local ns
2/db
.6a
.00.policy.
local
206 echo "I:running dig to cache CNAME record (${t})"
207 $DIG $DIGOPTS @
10.53.0.2 -p 5300 www.
test.example.org CNAME
> dig.out.
${t}
209 echo "I:suspending authority server"
210 kill -TSTP `cat ns1/named.pid`
211 echo "I:adding an NSDNAME policy"
212 cp ns
2/db
.6b
.00.policy.
local ns
2/db
.6a
.00.policy.
local
213 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reload
6a
.00.policy.
local 2>&1 |
sed 's/^/I:ns2 /'
216 echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})"
217 $DIG $DIGOPTS @
10.53.0.2 -p 5300 www.
test.example.org A
> dig.out.
${t} &
219 echo "I:removing the policy zone"
220 cp ns
2/named.default.conf ns
2/db
.6a
.00.policy.
local
221 $RNDC -c ..
/common
/rndc.conf
-s 10.53.0.2 -p 9953 reload
6a
.00.policy.
local 2>&1 |
sed 's/^/I:ns2 /'
223 echo "I:resuming authority server"
224 kill -CONT `cat ns1/named.pid`
225 for n
in 1 2 3 4 5 6 7 8 9; do
227 [ -s dig.out.
${t} ] ||
continue
228 grep "status: NOERROR" dig.out.
${t} > /dev
/null
2>&1 ||
{
229 echo "I:test ${t} failed"
234 # Check CLIENT-IP behavior
236 echo "I:testing CLIENT-IP behavior (${t})"
238 $DIG $DIGOPTS l2.l1.l0 a @
10.53.0.2 -p 5300 -b 10.53.0.4 > dig.out.
${t}
239 grep "status: NOERROR" dig.out.
${t} > /dev
/null
2>&1 ||
{
240 echo "I:test $t failed: query failed"
243 grep "^l2.l1.l0.[[:space:]]*[0-9]*[[:space:]]*IN[[:space:]]*A[[:space:]]*10.53.0.2" dig.out.
${t} > /dev
/null
2>&1 ||
{
244 echo "I:test $t failed: didn't get expected answer"