1#!/bin/sh 2# 3# Copyright (C) 2010, 2011 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.4.54.2 2011/06/17 23:47:11 tbox Exp $ 18 19SYSTEMTESTTOP=.. 20. $SYSTEMTESTTOP/conf.sh 21 22DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300" 23status=0 24n=0 25 26echo "I:checking normally loaded zone ($n)" 27ret=0 28$DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n || ret=1 29grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 30grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1 31n=`expr $n + 1` 32if [ $ret != 0 ]; then echo "I:failed"; fi 33status=`expr $status + $ret` 34 35echo "I:checking previously added zone ($n)" 36ret=0 37$DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n || ret=1 38grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 39grep '^a.previous.example' dig.out.ns2.$n > /dev/null || ret=1 40n=`expr $n + 1` 41if [ $ret != 0 ]; then echo "I:failed"; fi 42status=`expr $status + $ret` 43 44echo "I:adding new zone ($n)" 45ret=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 48grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 49grep '^a.added.example' dig.out.ns2.$n > /dev/null || ret=1 50n=`expr $n + 1` 51if [ $ret != 0 ]; then echo "I:failed"; fi 52status=`expr $status + $ret` 53 54echo "I:adding new zone with missing master file ($n)" 55ret=0 56$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.pre.$n || ret=1 57grep "status: REFUSED" dig.out.ns2.pre.$n > /dev/null || ret=1 58$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 59grep "file not found" rndc.out.ns2.$n > /dev/null || ret=1 60$DIG $DIGOPTS +all @10.53.0.2 a.missing.example a > dig.out.ns2.post.$n || ret=1 61grep "status: REFUSED" dig.out.ns2.post.$n > /dev/null || ret=1 62$PERL ../digcomp.pl dig.out.ns2.pre.$n dig.out.ns2.post.$n || ret=1 63n=`expr $n + 1` 64if [ $ret != 0 ]; then echo "I:failed"; fi 65status=`expr $status + $ret` 66 67echo "I:deleting previously added zone ($n)" 68ret=0 69$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone previous.example 2>&1 | sed 's/^/I:ns2 /' 70$DIG $DIGOPTS @10.53.0.2 a.previous.example a > dig.out.ns2.$n 71grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1 72grep '^a.previous.example' dig.out.ns2.$n > /dev/null && ret=1 73n=`expr $n + 1` 74if [ $ret != 0 ]; then echo "I:failed"; fi 75status=`expr $status + $ret` 76 77echo "I:deleting newly added zone ($n)" 78ret=0 79$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone added.example 2>&1 | sed 's/^/I:ns2 /' 80$DIG $DIGOPTS @10.53.0.2 a.added.example a > dig.out.ns2.$n 81grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1 82grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1 83n=`expr $n + 1` 84if [ $ret != 0 ]; then echo "I:failed"; fi 85status=`expr $status + $ret` 86 87echo "I:attempt to delete a normally-loaded zone ($n)" 88ret=0 89$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone normal.example 2> rndc.out.ns2.$n 90grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1 91$DIG $DIGOPTS @10.53.0.2 a.normal.example a > dig.out.ns2.$n 92grep 'status: NOERROR' dig.out.ns2.$n > /dev/null || ret=1 93grep '^a.normal.example' dig.out.ns2.$n > /dev/null || ret=1 94n=`expr $n + 1` 95if [ $ret != 0 ]; then echo "I:failed"; fi 96status=`expr $status + $ret` 97 98echo "I:reconfiguring server with multiple views" 99rm -f ns2/named.conf 100cp -f ns2/named2.conf ns2/named.conf 101$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /' 102sleep 5 103 104echo "I:adding new zone to external view ($n)" 105# NOTE: The internal view has "recursion yes" set, and so queries for 106# nonexistent zones should return NOERROR. The external view is 107# "recursion no", so queries for nonexistent zones should return 108# REFUSED. This behavior should be the same regardless of whether 109# the zone does not exist because a) it has not yet been loaded, b) 110# it failed to load, or c) it has been deleted. 111ret=0 112$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.intpre.$n || ret=1 113grep 'status: NOERROR' dig.out.ns2.intpre.$n > /dev/null || ret=1 114$DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.extpre.$n || ret=1 115grep 'status: REFUSED' dig.out.ns2.extpre.$n > /dev/null || ret=1 116$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 /' 117$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1 118grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1 119$DIG +norec $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1 120grep 'status: NOERROR' dig.out.ns2.ext.$n > /dev/null || ret=1 121grep '^a.added.example' dig.out.ns2.ext.$n > /dev/null || ret=1 122n=`expr $n + 1` 123if [ $ret != 0 ]; then echo "I:failed"; fi 124status=`expr $status + $ret` 125 126echo "I:deleting newly added zone ($n)" 127ret=0 128$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'added.example in external' 2>&1 | sed 's/^/I:ns2 /' 129$DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.$n || ret=1 130grep 'status: REFUSED' dig.out.ns2.$n > /dev/null || ret=1 131grep '^a.added.example' dig.out.ns2.$n > /dev/null && ret=1 132n=`expr $n + 1` 133if [ $ret != 0 ]; then echo "I:failed"; fi 134status=`expr $status + $ret` 135 136echo "I:attempting to add zone to internal view ($n)" 137ret=0 138$DIG +norec $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.pre.$n || ret=1 139grep 'status: NOERROR' dig.out.ns2.pre.$n > /dev/null || ret=1 140$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 141grep "permission denied" rndc.out.ns2.$n > /dev/null || ret=1 142$DIG $DIGOPTS @10.53.0.2 -b 10.53.0.2 a.added.example a > dig.out.ns2.int.$n || ret=1 143grep 'status: NOERROR' dig.out.ns2.int.$n > /dev/null || ret=1 144$DIG $DIGOPTS @10.53.0.4 -b 10.53.0.4 a.added.example a > dig.out.ns2.ext.$n || ret=1 145grep 'status: REFUSED' dig.out.ns2.ext.$n > /dev/null || ret=1 146n=`expr $n + 1` 147if [ $ret != 0 ]; then echo "I:failed"; fi 148status=`expr $status + $ret` 149 150echo "I:ensure the configuration context is cleaned up correctly ($n)" 151ret=0 152$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig > /dev/null 2>&1 || ret=1 153sleep 5 154$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 status > /dev/null 2>&1 || ret=1 155n=`expr $n + 1` 156if [ $ret != 0 ]; then echo "I:failed"; fi 157status=`expr $status + $ret` 158 159echo "I:exit status: $status" 160exit $status 161