2e6bbf466d0f725ba5f46410e91ed3761ff723df
[tridge/bind9.git] / bin / tests / system / addzone / tests.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
4 #
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.
8 #
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.
16
17 # $Id: tests.sh,v 1.2.2.2 2010/08/11 18:19:55 each Exp $
18
19 SYSTEMTESTTOP=..
20 . $SYSTEMTESTTOP/conf.sh
21
22 DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300"
23 status=0
24 n=0
25
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`
34
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`
43
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`
53
54 echo "I:deleting previously added zone ($n)"
55 ret=0
56 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /'
57 $DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n
58 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
59 grep '^a.previous.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`
63
64 echo "I:deleting newly added zone ($n)"
65 ret=0
66 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone added.example 2>&1 | sed 's/^/I:ns2 /'
67 $DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n
68 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
69 grep '^a.added.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`
73
74 echo "I:attempt to delete a normally-loaded zone (should fail) ($n)"
75 ret=0
76 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2>&1 | sed 's/^/I:ns2 /'
77 $DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n
78 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
79 grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1
80 n=`expr $n + 1`
81 if [ $ret != 0 ]; then echo "I:failed"; fi
82 status=`expr $status + $ret`
83
84 echo "I:reconfiguring server with multiple views"
85 rm -f ns2/named.conf 
86 cp -f ns2/named2.conf ns2/named.conf
87 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /'
88 sleep 5
89
90 echo "I:adding new zone to external view ($n)"
91 ret=0
92 $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 /'
93 $DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1
94 $DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1
95 grep 'status: REFUSED' dig.out.ns2.int.$n > /dev/null || ret=1
96 grep 'status: NOERROR' dig.out.ns2.ext.$n > /dev/null || ret=1
97 grep '^a.added.example' dig.out.ns2.ext.$n > /dev/null || ret=1
98 n=`expr $n + 1`
99 if [ $ret != 0 ]; then echo "I:failed"; fi
100 status=`expr $status + $ret`
101
102 echo "I:deleting newly added zone ($n)"
103 ret=0
104 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'added.example in external' 2>&1 | sed 's/^/I:ns2 /'
105 $DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.$n || ret=1
106 grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1
107 grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1
108 n=`expr $n + 1`
109 if [ $ret != 0 ]; then echo "I:failed"; fi
110 status=`expr $status + $ret`
111
112 echo "I:attempting to add zone to internal view (should fail) ($n)"
113 ret=0
114 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'added.example in internal { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
115 $DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.$n || ret=1
116 grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1
117 n=`expr $n + 1`
118 if [ $ret != 0 ]; then echo "I:failed"; fi
119 status=`expr $status + $ret`
120
121 echo "I:exit status: $status"
122 exit $status