]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
zonemd, unit test for unbound-control auth_zone_reload with zonemd.
authorW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 23 Oct 2020 10:10:30 +0000 (12:10 +0200)
committerW.C.A. Wijngaards <wouter@nlnetlabs.nl>
Fri, 23 Oct 2020 10:10:30 +0000 (12:10 +0200)
testdata/zonemd_reload.tdir/zonemd_reload.conf [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.dsc [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.post [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.pre [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.test [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.testns [new file with mode: 0644]
testdata/zonemd_reload.tdir/zonemd_reload.zone [new file with mode: 0644]

diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.conf b/testdata/zonemd_reload.tdir/zonemd_reload.conf
new file mode 100644 (file)
index 0000000..27bdb44
--- /dev/null
@@ -0,0 +1,22 @@
+server:
+       verbosity: 7
+       # num-threads: 1
+       interface: 127.0.0.1
+       port: @PORT@
+       use-syslog: no
+       directory: ""
+       pidfile: "unbound.pid"
+       chroot: ""
+       username: ""
+       do-not-query-localhost: no
+       use-caps-for-id: yes
+remote-control:
+       control-enable: yes
+       control-interface: @CONTROL_PATH@/controlpipe.@CONTROL_PID@
+       control-use-cert: no
+auth-zone:
+       name: "example.com"
+       for-upstream: yes
+       for-downstream: yes
+       zonefile: "zonemd_reload.zone"
+       #master: "127.0.0.1@@TOPORT@"
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.dsc b/testdata/zonemd_reload.tdir/zonemd_reload.dsc
new file mode 100644 (file)
index 0000000..016c3d6
--- /dev/null
@@ -0,0 +1,16 @@
+BaseName: zonemd_reload
+Version: 1.0
+Description: ZONEMD check after auth_zone_reload
+CreationDate: Tue 23 Oct 12:00:00 CEST 2020
+Maintainer: dr. W.C.A. Wijngaards
+Category: 
+Component:
+CmdDepends: 
+Depends: 
+Help:
+Pre: zonemd_reload.pre
+Post: zonemd_reload.post
+Test: zonemd_reload.test
+AuxFiles: 
+Passed:
+Failure:
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.post b/testdata/zonemd_reload.tdir/zonemd_reload.post
new file mode 100644 (file)
index 0000000..5e31508
--- /dev/null
@@ -0,0 +1,14 @@
+# #-- zonemd_reload.post --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# source the test var file when it's there
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+#
+# do your teardown here
+. ../common.sh
+echo "> cat logfiles"
+cat fwd.log 
+cat unbound.log
+kill_pid $FWD_PID
+kill_pid $UNBOUND_PID
+rm -f $CONTROL_PATH/controlpipe.$CONTROL_PID
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.pre b/testdata/zonemd_reload.tdir/zonemd_reload.pre
new file mode 100644 (file)
index 0000000..fa5e4ca
--- /dev/null
@@ -0,0 +1,35 @@
+# #-- zonemd_reload.pre--#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+. ../common.sh
+get_random_port 2
+UNBOUND_PORT=$RND_PORT
+FWD_PORT=$(($RND_PORT + 1))
+echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
+echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
+
+# start forwarder
+get_ldns_testns
+$LDNS_TESTNS -p $FWD_PORT zonemd_reload.testns >fwd.log 2>&1 &
+FWD_PID=$!
+echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
+
+# make config file
+CONTROL_PATH=/tmp
+CONTROL_PID=$$
+sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's?@CONTROL_PATH\@?'$CONTROL_PATH'?' -e 's/@CONTROL_PID@/'$CONTROL_PID'/' < zonemd_reload.conf > ub.conf
+# start unbound in the background
+PRE="../.."
+$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
+UNBOUND_PID=$!
+echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
+echo "CONTROL_PATH=$CONTROL_PATH" >> .tpkg.var.test
+echo "CONTROL_PID=$CONTROL_PID" >> .tpkg.var.test
+
+cat .tpkg.var.test
+wait_ldns_testns_up fwd.log
+wait_unbound_up unbound.log
+
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.test b/testdata/zonemd_reload.tdir/zonemd_reload.test
new file mode 100644 (file)
index 0000000..5ae1d9b
--- /dev/null
@@ -0,0 +1,74 @@
+# #-- zonemd_reload.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+PRE="../.."
+# do the test
+echo "> dig www.example.com."
+dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       sleep 1
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       sleep 1
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       sleep 1
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       sleep 10
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+if grep SERVFAIL outfile; then
+       echo "> try again"
+       sleep 10
+       dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
+fi
+echo "> cat logfiles"
+cat fwd.log 
+cat unbound.log
+echo "> check answer"
+if grep www.example.com outfile | grep "127.0.0.1"; then
+       echo "OK"
+else
+       echo "Not OK"
+       exit 1
+fi
+
+echo "> unbound-control status"
+$PRE/unbound-control -c ub.conf status
+if test $? -ne 0; then
+       echo "wrong exit value."
+       exit 1
+else
+       echo "exit value: OK"
+fi
+
+echo "> unbound-control auth_zone_reload example.com"
+$PRE/unbound-control -c ub.conf auth_zone_reload example.com 2>&1 | tee outfile
+if test $? -ne 0; then
+       echo "wrong exit value."
+       exit 1
+fi
+echo "> check unbound-control output"
+if grep "example.com: ZONEMD verification successful" outfile; then
+       echo "OK"
+else
+       echo "Not OK"
+       exit 1
+fi
+
+exit 0
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.testns b/testdata/zonemd_reload.tdir/zonemd_reload.testns
new file mode 100644 (file)
index 0000000..f1678a1
--- /dev/null
@@ -0,0 +1,27 @@
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR AA NOERROR
+SECTION QUESTION
+example.com. IN SOA
+SECTION ANSWER
+example.com. IN SOA ns.example.com. hostmaster.example.com. 1 3600 900 86400 3600
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+ADJUST copy_id
+REPLY QR AA NOERROR
+SECTION QUESTION
+example.com. IN AXFR
+SECTION ANSWER
+example.com. IN SOA ns.example.com. hostmaster.example.com. 1 3600 900 86400 3600
+example.com.   IN NS   ns.example.net.
+EXTRA_PACKET
+REPLY QR AA NOERROR
+SECTION QUESTION
+example.com. IN AXFR
+SECTION ANSWER
+www.example.com. IN A  1.2.3.4
+example.com. IN SOA ns.example.com. hostmaster.example.com. 1 3600 900 86400 3600
+ENTRY_END
diff --git a/testdata/zonemd_reload.tdir/zonemd_reload.zone b/testdata/zonemd_reload.tdir/zonemd_reload.zone
new file mode 100644 (file)
index 0000000..16b631c
--- /dev/null
@@ -0,0 +1,8 @@
+example.com. IN SOA ns.example.com. hostmaster.example.com. 200154054 28800 7200 604800 3600
+example.com. IN NS ns.example.com.
+example.com. IN ZONEMD 200154054 1 2 EFAA5B78B38AB1C45DE57B8167BCCE906451D0E72118E1F5E80B5F0C3CF04BFFC65D53C011185528EAD439D6F3A02F511961E090E5E4E0DFA013BD276D728B22
+www.example.com. IN A 127.0.0.1
+ns.example.com. IN A 127.0.0.1
+bar.example.com. IN A 1.2.3.4
+ding.example.com. IN A 1.2.3.4
+foo.example.com. IN A 1.2.3.4