]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Test showzone and modzone on configured zone
authorMatthijs Mekking <matthijs@isc.org>
Fri, 13 Mar 2026 10:13:35 +0000 (11:13 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 16 Mar 2026 14:18:39 +0000 (15:18 +0100)
Add test cases for 'rndc showzone' and 'rndc modzone' on a zone
that was configured in named.conf. This should not crash.

bin/tests/system/addzone/tests.sh

index a59bc355d9334ee62300ba571ba5ef9f0643ee8d..0cf8be2a7537ac51e79ee37106e1753c46790814 100755 (executable)
@@ -36,6 +36,26 @@ n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
+# showzone
+echo_i "showzone normally loaded zone ($n)"
+ret=0
+$RNDCCMD 10.53.0.2 showzone normal.example >rndc.out.ns2.$n
+expected='zone "normal.example" { type primary; file "normal.db"; };'
+[ "$(cat rndc.out.ns2.$n)" = "$expected" ] || ret=1
+n=$((n + 1))
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status + ret))
+# modzone
+echo_i "modzone normally loaded zone ($n)"
+ret=0
+$RNDCCMD 10.53.0.2 modzone normal.example '{ type primary; file "normal.db"; };' >rndc.out.ns2.$n
+grep "" rndc.out.ns2.$n >/dev/null || ret=1
+grep "zone 'normal.example' must also be reconfigured in" rndc.out.ns2.$n >/dev/null || ret=1
+grep "named.conf to make changes permanent." rndc.out.ns2.$n >/dev/null || ret=1
+n=$((n + 1))
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=$((status + ret))
+
 # When LMDB support is compiled in, this tests that migration from
 # NZF to NZD occurs during named startup
 echo_i "checking previously added zone ($n)"
@@ -263,7 +283,7 @@ status=$((status + ret))
 echo_i "delete a normally-loaded zone ($n)"
 ret=0
 $RNDCCMD 10.53.0.2 delzone normal.example >rndc.out.ns2.$n 2>&1
-grep "is no longer active and will be deleted" rndc.out.ns2.$n >/dev/null || ret=11
+grep "is no longer active and will be deleted" rndc.out.ns2.$n >/dev/null || ret=1
 grep "To keep it from returning when the server is restarted" rndc.out.ns2.$n >/dev/null || ret=1
 grep "must also be removed from named.conf." rndc.out.ns2.$n >/dev/null || ret=1
 _check_delete_normally_loaded_zone() (
@@ -271,7 +291,6 @@ _check_delete_normally_loaded_zone() (
     && grep 'status: REFUSED' dig.out.ns2.$n >/dev/null
 )
 retry_quiet 5 _check_delete_normally_loaded_zone || ret=1
-
 n=$((n + 1))
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))