tests.sh revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
#
# Copyright (C) 2010-2016 Internet Systems Consortium, Inc. ("ISC")
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p 5300"
status=0
n=0
echo "I:checking normally loaded zone ($n)"
ret=0
n=`expr $n + 1`
echo "I:checking previously added zone ($n)"
ret=0
n=`expr $n + 1`
echo "I:adding new zone ($n)"
ret=0
$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 /'
n=`expr $n + 1`
echo "I:checking addzone errors are logged correctly"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone bad.example '{ type mister; };' 2>&1 | grep 'unexpected token' > /dev/null 2>&1 || ret=1
n=`expr $n + 1`
echo "I:checking modzone errors are logged correctly"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 modzone added.example '{ type mister; };' 2>&1 | grep 'unexpected token' > /dev/null 2>&1 || ret=1
n=`expr $n + 1`
echo "I:adding a zone that requires quotes ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"32/1.0.0.127-in-addr.added.example" { check-names ignore; type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
n=`expr $n + 1`
echo "I:adding a zone with a quote in the name ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone '"foo\"bar.example" { check-names ignore; type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
n=`expr $n + 1`
echo "I:adding new zone with missing master file ($n)"
ret=0
$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
n=`expr $n + 1`
echo "I:verifying no comments in nzf file ($n)"
ret=0
n=`expr $n + 1`
echo "I:checking rndc showzone with previously added zone ($n)"
ret=0
expected='zone "previous.example" { type master; file "previous.db"; };'
n=`expr $n + 1`
echo "I:deleting previously added zone ($n)"
ret=0
n=`expr $n + 1`
echo "I:checking nzf file now has comment ($n)"
ret=0
n=`expr $n + 1`
echo "I:deleting newly added zone ($n)"
ret=0
n=`expr $n + 1`
echo "I:deleting newly added zone with escaped quote ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone "foo\\\"bar.example" 2>&1 | sed 's/^/I:ns2 /'
n=`expr $n + 1`
echo "I:checking rndc showzone with a normally-loaded zone ($n)"
ret=0
expected='zone "normal.example" { type master; file "normal.db"; };'
n=`expr $n + 1`
echo "I:checking rndc showzone with a normally-loaded zone with trailing dot ($n)"
ret=0
expected='zone "finaldot.example." { type master; file "normal.db"; };'
n=`expr $n + 1`
echo "I:delete a normally-loaded zone ($n)"
ret=0
n=`expr $n + 1`
echo "I:attempting to add master zone with inline signing ($n)"
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inline.example { type master; file "inline.db"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
do
ret=0
[ $ret = 0 ] && break
sleep 1
done
n=`expr $n + 1`
echo "I:attempting to add master zone with inline signing and missing master ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlinemissing.example { type master; file "missing.db"; inline-signing yes; };' 2> rndc.out.ns2.$n
n=`expr $n + 1`
echo "I:attempting to add slave zone with inline signing ($n)"
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlineslave.example { type slave; masters { 10.53.0.1; }; file "inlineslave.bk"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
do
ret=0
[ $ret = 0 ] && break
sleep 1
done
n=`expr $n + 1`
echo "I:attempting to delete slave zone with inline signing ($n)"
ret=0
do
sleep 1
done
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone inlineslave.example 2>&1 > rndc.out2.test$n
test -f inlineslave.bk ||
}
test ! -f inlineslave.bk.signed ||
}
n=`expr $n + 1`
echo "I:restoring slave zone with inline signing ($n)"
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'inlineslave.example { type slave; masters { 10.53.0.1; }; file "inlineslave.bk"; inline-signing yes; };' 2>&1 | sed 's/^/I:ns2 /'
do
ret=0
[ $ret = 0 ] && break
sleep 1
done
n=`expr $n + 1`
echo "I:deleting slave zone with automatic zone file removal ($n)"
ret=0
do
sleep 1
done
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone -clean inlineslave.example 2>&1 > /dev/null
do
ret=0
[ $ret = 0 ] && break
sleep 1
done
n=`expr $n + 1`
echo "I:modifying zone configuration ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 addzone 'mod.example { type master; file "added.db"; };' 2>&1 | sed 's/^/I:ns2 /'
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 modzone 'mod.example { type master; file "added.db"; allow-query { none; }; };' 2>&1 | sed 's/^/I:ns2 /'
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone mod.example | grep 'allow-query { "none"; };' > /dev/null 2>&1 || ret=1
n=`expr $n + 1`
echo "I:reconfiguring server with multiple views"
sleep 5
echo "I:adding new zone to external view ($n)"
# NOTE: The internal view has "recursion yes" set, and so queries for
# nonexistent zones should return NOERROR. The external view is
# "recursion no", so queries for nonexistent zones should return
# REFUSED. This behavior should be the same regardless of whether
# the zone does not exist because a) it has not yet been loaded, b)
# it failed to load, or c) it has been deleted.
ret=0
$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 /'
n=`expr $n + 1`
echo "I:checking new nzf file has comment ($n)"
ret=0
n=`expr $n + 1`
echo "I:checking rndc reload causes named to reload the external view's NZF file ($n)"
ret=0
n=`expr $n + 1`
echo "I:checking rndc showzone with newly added zone ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 showzone added.example in external > rndc.out.ns2.$n
expected='zone "added.example" in external { type master; file "added.db"; };'
n=`expr $n + 1`
echo "I:deleting newly added zone ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'added.example in external' 2>&1 | sed 's/^/I:ns2 /'
n=`expr $n + 1`
echo "I:attempting to add zone to internal view ($n)"
ret=0
$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
n=`expr $n + 1`
echo "I:attempting to delete a policy zone ($n)"
ret=0
$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 delzone 'policy in internal' 2> rndc.out.ns2.$n >&1
n=`expr $n + 1`
echo "I:ensure the configuration context is cleaned up correctly ($n)"
ret=0
sleep 5
n=`expr $n + 1`
echo "I:exit status: $status"