5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer#!/bin/sh
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2000, 2001, 2004, 2007, 2012-2014, 2016 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
d3498432822fb487e58f8f72bb5f880dd8307d7dMichael Sawyer
70e5a7403f0e0a3bd292b8287c5fed5772c15270Automatic Updater# $Id: tests.sh,v 1.30 2007/06/19 23:47:06 tbox Exp $
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
813d6c9781d1fb48bb5c1d6d3415e65f7be5eeb0Andreas GustafssonSYSTEMTESTTOP=..
813d6c9781d1fb48bb5c1d6d3415e65f7be5eeb0Andreas Gustafsson. $SYSTEMTESTTOP/conf.sh
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafssonstatus=0
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:fetching a.example from ns2's initial configuration"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noauth \
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson a.example. @10.53.0.2 any -p 5300 > dig.out.ns2.1 || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrencegrep ";" dig.out.ns2.1 # XXXDCL why is this here?
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:fetching a.example from ns3's initial configuration"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noauth \
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson a.example. @10.53.0.3 any -p 5300 > dig.out.ns3.1 || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrencegrep ";" dig.out.ns3.1 # XXXDCL why is this here?
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
92103a4e2cda870f4802804202ae30eb837da17fAndreas Gustafssonecho "I:copying in new configurations for ns2 and ns3"
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyerrm -f ns2/named.conf ns3/named.conf ns2/example.db
fa7ee558e0536a94bfdb154a7c7ba298535459c4Mark Andrewscp -f ns2/named2.conf ns2/named.conf
fa7ee558e0536a94bfdb154a7c7ba298535459c4Mark Andrewscp -f ns3/named2.conf ns3/named.conf
fa7ee558e0536a94bfdb154a7c7ba298535459c4Mark Andrewscp -f ns2/example2.db ns2/example.db
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence
d0dc01dd9de4c90e0adb01c3e8a51d74bc3d3559Brian Wellingtonecho "I:reloading ns2 and ns3 with rndc"
c877d7db8f60734d272ace824c04bce9b0a1e8feAndreas Gustafsson$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 2>&1 | sed 's/^/I:ns2 /'
c877d7db8f60734d272ace824c04bce9b0a1e8feAndreas Gustafsson$RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 reload 2>&1 | sed 's/^/I:ns3 /'
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence
d0dc01dd9de4c90e0adb01c3e8a51d74bc3d3559Brian Wellingtonecho "I:sleeping for 20 seconds"
d0dc01dd9de4c90e0adb01c3e8a51d74bc3d3559Brian Wellingtonsleep 20
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:fetching a.example from ns2's 10.53.0.4, source address 10.53.0.4"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noauth \
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence -b 10.53.0.4 a.example. @10.53.0.4 any -p 5300 > dig.out.ns4.2 \
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrencegrep ";" dig.out.ns4.2 # XXXDCL why is this here?
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:fetching a.example from ns2's 10.53.0.2, source address 10.53.0.2"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noauth \
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence -b 10.53.0.2 a.example. @10.53.0.2 any -p 5300 > dig.out.ns2.2 \
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrencegrep ";" dig.out.ns2.2 # XXXDCL why is this here?
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:fetching a.example from ns3's 10.53.0.3, source address defaulted"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$DIG +tcp +noadd +nosea +nostat +noquest +nocomm +nocmd +noauth \
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson @10.53.0.3 a.example. any -p 5300 > dig.out.ns3.2 || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrencegrep ";" dig.out.ns3.2 # XXXDCL why is this here?
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:comparing ns3's initial a.example to one from reconfigured 10.53.0.2"
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson$PERL ../digcomp.pl dig.out.ns3.1 dig.out.ns2.2 || status=1
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:comparing ns3's initial a.example to one from reconfigured 10.53.0.3"
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson$PERL ../digcomp.pl dig.out.ns3.1 dig.out.ns3.2 || status=1
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:comparing ns2's initial a.example to one from reconfigured 10.53.0.4"
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence$PERL ../digcomp.pl dig.out.ns2.1 dig.out.ns4.2 || status=1
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrenceecho "I:comparing ns2's initial a.example to one from reconfigured 10.53.0.3"
0f8a8f4552650459bde4b614d230e1f2abd5e684Andreas Gustafssonecho "I:(should be different)"
0f8a8f4552650459bde4b614d230e1f2abd5e684Andreas Gustafssonif $PERL ../digcomp.pl dig.out.ns2.1 dig.out.ns3.2 >/dev/null
0f8a8f4552650459bde4b614d230e1f2abd5e684Andreas Gustafssonthen
74c2797077faecf2034ef96e5452f09fd18e2ac4David Lawrence echo "I:no differences found. something's wrong."
722cac3cdcc5385ab64fa2d6c7f48ce3b9a68331Andreas Gustafsson status=1
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyerfi
5a3e08cbb2fc02f38edd784be8fc0549b92f02e8Michael Sawyer
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntecho "I:updating cloned zone in internal view"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt$NSUPDATE << EOF
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntserver 10.53.0.2 5300
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntzone clone
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntupdate add b.clone. 300 in a 10.1.0.3
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntsend
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan HuntEOF
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntecho "I:sleeping to allow update to take effect"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntsleep 5
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntecho "I:verifying update affected both views"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntret=0
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntone=`$DIG +tcp +short -p 5300 -b 10.53.0.2 @10.53.0.2 b.clone a`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunttwo=`$DIG +tcp +short -p 5300 -b 10.53.0.4 @10.53.0.2 b.clone a`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ "$one" != "$two" ]; then
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt echo "'$one' does not match '$two'"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt ret=1
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntfi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ $ret != 0 ]; then echo "I:failed"; fi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntstatus=`expr $status + $ret`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntecho "I:verifying forwarder in cloned zone works"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntret=0
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntone=`$DIG +tcp +short -p 5300 -b 10.53.0.2 @10.53.0.2 child.clone txt`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunttwo=`$DIG +tcp +short -p 5300 -b 10.53.0.4 @10.53.0.2 child.clone txt`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntthree=`$DIG +tcp +short -p 5300 @10.53.0.3 child.clone txt`
3ac9ef6a6d3ec74c8b8cdf9916fc83ae3625385bMark Andrewsfour=`$DIG +tcp +short -p 5300 @10.53.0.5 child.clone txt`
ced4f794cf7149e2af628e872f3608d5f9b5fbc7Mark Andrewsecho "$three" | grep NS3 > /dev/null || { ret=1; echo "expected response from NS3 got '$three'"; }
ced4f794cf7149e2af628e872f3608d5f9b5fbc7Mark Andrewsecho "$four" | grep NS5 > /dev/null || { ret=1; echo "expected response from NS5 got '$four'"; }
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ "$one" = "$two" ]; then
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt echo "'$one' matches '$two'"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt ret=1
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntfi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ "$one" != "$three" ]; then
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt echo "'$one' does not match '$three'"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt ret=1
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntfi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ "$two" != "$four" ]; then
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt echo "'$two' does not match '$four'"
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt ret=1
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntfi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntif [ $ret != 0 ]; then echo "I:failed"; fi
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Huntstatus=`expr $status + $ret`
434bfc3dfa2003ba0dd4b2392286806131fd6724Evan Hunt
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrewsif $SHELL ../testcrypto.sh
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrewsthen
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews echo "I:verifying inline zones work with views"
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews ret=0
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews $DIG @10.53.0.2 -p 5300 -b 10.53.0.2 +dnssec DNSKEY inline > dig.out.internal
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews $DIG @10.53.0.2 -p 5300 -b 10.53.0.5 +dnssec DNSKEY inline > dig.out.external
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews grep "ANSWER: 4," dig.out.internal > /dev/null || ret=1
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews grep "ANSWER: 4," dig.out.external > /dev/null || ret=1
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews int=`awk '$4 == "DNSKEY" { print $8 }' dig.out.internal | sort`
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews ext=`awk '$4 == "DNSKEY" { print $8 }' dig.out.external | sort`
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews test "$int" != "$ext" || ret=1
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews if [ $ret != 0 ]; then echo "I:failed"; fi
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrews status=`expr $status + $ret`
39fb5f2a5d9ba3ca2d120c3c9a4510709d80bf19Mark Andrewsfi
b24061719ced97ecdbc7cfcf925c217d0dd80834Mark Andrews
1e8c2e72e7d0f48ac37b9b15712e638631b3b619Brian Wellingtonecho "I:exit status: $status"
3635d8f9104e70e141a8f191a0e6c1502ceed2f3Mark Andrews[ $status -eq 0 ] || exit 1