tests.sh revision c19cfefe7e345c37ef3bb98b0db2d14fe7b1d583
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
703e1c0bb66f3cd3d300358ca0c1fdf3cb5fb1c5Brian Wellington# Permission to use, copy, modify, and/or distribute this software for any
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# purpose with or without fee is hereby granted, provided that the above
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence# copyright notice and this permission notice appear in all copies.
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# PERFORMANCE OF THIS SOFTWARE.
a14613fce99dee3cad5bf842fd6be78f8e463582Brian Wellington# $Id: tests.sh,v 1.11 2012/01/07 00:19:59 each Exp $
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrence# test response policy zones (RPZ)
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrencens2=10.53.0.2 # server whose answers are rewritten
279c6ec074be17dce62dd1b2c6ed7c2cc56a7b78David Lawrencens3=10.53.0.3 # resolve that does the rewriting
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob HalleyRNDCCMD="$RNDC -c ../common/rndc.conf -s $ns3 -p 9953"
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleywhile getopts "x" c; do
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halleyshift `expr $OPTIND - 1 || true`
90407942d3afe50f04ccea361de3b164a5a1702dMichael Graff# really quit on control-C
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halley #echo I:dig +noadd +noauth +nosearch +time=1 +tries=1 -p 5300 $* 1>&2
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halley $DIG +noadd +noauth +nosearch +time=1 +tries=1 -p 5300 $*
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halley# set DIGNM=file name for dig output
8d4257cff01b3821abcb9a21f46c6c6a43bb1e72Bob Halley while test -f $DIGNM; do
194b6a25192581bbc8ec731e32e8989042b202a4Michael Graff# (re)load the reponse policy zones with the rules in the file $TEST_FILE
5c00d1c90030a311d2700970fa7cffc8f828a48cBob Halley if $NSUPDATE -v $TEST_FILE; then : ; else
5c00d1c90030a311d2700970fa7cffc8f828a48cBob Halley echo "I:failed to update policy zone with $TEST_FILE"
0eb2572d79822d02ea05448ce4e5f1759c73d171Michael Graff (cd ..; $PERL start.pl --noclean --restart rpz ns3)
4108eed5092156cf0407a97a9bd8ab7775164694Brian Wellington $RNDCCMD status >/dev/null 2>&1 && return 0
17012a879742ceb6561dcc4ae3bcd4ff80dc9887David Lawrence# $1=message $2=optional test file name
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence sed -e 's/[ ]add[ ]/ delete /' $TEST_FILE | $NSUPDATE
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence# $1=dig args $2=other dig output file
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence #ckalive "I:server crashed by 'dig $1'" || return 1
49a2cf8f211213712d452287ae8e121cf59e3178David Lawrence if $PERL ../digcomp.pl $DIGNM $2 >/dev/null; then
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington# check only that the server does not crash
489b76292622f5bc18bf1a18845f8166a73bd797Brian Wellington# $1=target domain $2=optional query type
5c00d1c90030a311d2700970fa7cffc8f828a48cBob Halley# check rewrite to NXDOMAIN
134ba0e08a0ae9a564a8d8628fc633377d3fc239Bob Halley# $1=target domain $2=optional query type
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# check rewrite to NODATA
a5d43b72413db3edd6b36a58f9bdf2cf6ff692f2Bob Halley# $1=target domain $2=optional query type
882350d11c90de9de6fc1cead25690c8114b0b95Michael Graff | sed -e 's/^[a-z].* IN CNAME /;xxx &/' >$DIGNM
15bfd48fc5552ff1aae766021f42a250c001a098Michael Graff# check rewrite to an address
882350d11c90de9de6fc1cead25690c8114b0b95Michael Graff# modify the output so that it is easily compared, but save the original line
882350d11c90de9de6fc1cead25690c8114b0b95Michael Graff# $1=IPv4 address, $2=target domain $3=optional query type
ADDR=$1
nochange .
# policies in ./test5 overridden by response-policy{} in ns3/named.conf
if test -z "$HAVE_CORE"; then
echo "I:exit status: $status"
exit $status