]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add statschannel test case for key removal
authorMatthijs Mekking <matthijs@isc.org>
Fri, 20 Aug 2021 13:08:29 +0000 (15:08 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Tue, 24 Aug 2021 07:07:15 +0000 (09:07 +0200)
Add a statschannel test case to confirm that when keys are removed
(in this case because of a dnssec-policy change), the corresponding
dnssec-sign stats are cleared and are no longer shown in the
statistics.

bin/tests/system/statschannel/ns2/named2.conf.in [new file with mode: 0644]
bin/tests/system/statschannel/tests.sh

diff --git a/bin/tests/system/statschannel/ns2/named2.conf.in b/bin/tests/system/statschannel/ns2/named2.conf.in
new file mode 100644 (file)
index 0000000..15c52d4
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 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/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+options {
+       query-source address 10.53.0.2;
+       notify-source 10.53.0.2;
+       transfer-source 10.53.0.2;
+       port @PORT@;
+       pid-file "named.pid";
+       listen-on { 10.53.0.2; };
+       listen-on-v6 { none; };
+       recursion no;
+       notify no;
+       minimal-responses no;
+       version none;  // make statistics independent of the version number
+};
+
+statistics-channels { inet 10.53.0.2 port @EXTRAPORT1@ allow { localhost; }; };
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
+
+dnssec-policy "manykeys" {
+       keys {
+               ksk lifetime unlimited algorithm 8;
+               zsk lifetime unlimited algorithm 8;
+       };
+};
+
+zone "example" {
+       type primary;
+       file "example.db";
+       allow-transfer { any; };
+};
+
+zone "dnssec" {
+       type primary;
+       file "dnssec.db.signed";
+       auto-dnssec maintain;
+       allow-update { any; };
+       zone-statistics full;
+       dnssec-dnskey-kskonly yes;
+       update-check-ksk yes;
+};
+
+zone "manykeys" {
+       type primary;
+       file "manykeys.db.signed";
+       allow-update { any; };
+       zone-statistics full;
+       dnssec-policy "manykeys";
+};
index 552ac0b738d78a54addd77e98f27240c55deafe4..bbbc8a0c97aa5055de68d139c1dfd27f875bf6f6 100644 (file)
@@ -345,5 +345,34 @@ if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 n=`expr $n + 1`
 
+# Test sign operations after dnssec-policy change (removing keys).
+ret=0
+copy_setports ns2/named2.conf.in ns2/named.conf
+$RNDCCMD 10.53.0.2 reload 2>&1 | sed 's/^/I:ns2 /'
+# This should trigger the resign of DNSKEY (+1 ksk), and SOA, NSEC,
+# TYPE65534 (+3 zsk). The dnssec-sign statistics for the removed keys should
+# be cleared and thus no longer visible. But NSEC and SOA are (mistakenly)
+# counted double, one time because of zone_resigninc and one time because of
+# zone_nsec3chain. So +5 zsk in total.
+echo "${refresh_prefix} ${zsk8_id}: 15" > zones.expect
+echo "${refresh_prefix} ${ksk8_id}: 2" >> zones.expect
+echo "${sign_prefix} ${zsk8_id}: 18" >> zones.expect
+echo "${sign_prefix} ${ksk8_id}: 2" >> zones.expect
+cat zones.expect | sort > zones.expect.$n
+rm -f zones.expect
+# Fetch and check the dnssec sign statistics.
+echo_i "fetching zone '$zone' stats data after dnssec-policy change ($n)"
+if [ $PERL_XML ]; then
+    getzones xml $zone x$n || ret=1
+    cmp zones.out.x$n zones.expect.$n || ret=1
+fi
+if [ $PERL_JSON ]; then
+    getzones json 2 j$n || ret=1
+    cmp zones.out.j$n zones.expect.$n || ret=1
+fi
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+n=`expr $n + 1`
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1