From: Matthijs Mekking Date: Tue, 30 Sep 2025 07:13:38 +0000 (+0200) Subject: Rewrite nsec3 system test to pytest (1/4) X-Git-Tag: v9.21.16~38^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e81cc1520a826a362b2fa31772733eb932180576;p=thirdparty%2Fbind9.git Rewrite nsec3 system test to pytest (1/4) This converts all the nsec3 system test cases prior to reconfiguring the name server. There are two main classes, one that tests the zone is correctly signed with NSEC, the other with NSEC3. Two extra tests for nsec3-dynamic-update-inline.kasp and nsec3-change.kasp are also rewritten. For the former, we need to change the 'nsupdate' definition to be able to set the expected RCODE. --- diff --git a/bin/tests/system/isctest/instance.py b/bin/tests/system/isctest/instance.py index 268dcf09d05..d6400c5e39b 100644 --- a/bin/tests/system/isctest/instance.py +++ b/bin/tests/system/isctest/instance.py @@ -154,7 +154,9 @@ class NamedInstance: return response - def nsupdate(self, update_msg: dns.message.Message): + def nsupdate( + self, update_msg: dns.message.Message, expected_rcode=dns.rcode.NOERROR + ): """ Issue a dynamic update to a server's zone. """ @@ -168,12 +170,14 @@ class NamedInstance: self.ip, self.ports.dns, timeout=3, - expected_rcode=dns.rcode.NOERROR, + expected_rcode=expected_rcode, ) except dns.exception.Timeout as exc: msg = f"update timeout for {zone}" raise dns.exception.Timeout(msg) from exc - debug(f"update of zone {zone} to server {self.ip} successful") + debug( + f"update of zone {zone} to server {self.ip} finished with {expected_rcode}" + ) return response def watch_log_from_start( diff --git a/bin/tests/system/nsec3/tests.sh b/bin/tests/system/nsec3/tests.sh index bcb1144adae..0414fb15f9a 100644 --- a/bin/tests/system/nsec3/tests.sh +++ b/bin/tests/system/nsec3/tests.sh @@ -235,159 +235,6 @@ key_clear "KEY2" key_clear "KEY3" key_clear "KEY4" -# Zone: nsec-to-nsec3.kasp. -set_zone_policy "nsec-to-nsec3.kasp" "nsec" 1 3600 -set_server "ns3" "10.53.0.3" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec - -if [ $RSASHA1_SUPPORTED = 1 ]; then - # Zone: rsasha1-to-nsec3.kasp. - set_zone_policy "rsasha1-to-nsec3.kasp" "rsasha1" 1 3600 - set_server "ns3" "10.53.0.3" - set_key_rsasha1_values "KEY1" - echo_i "initial check zone ${ZONE}" - check_nsec - - # Zone: rsasha1-to-nsec3-wait.kasp. - set_zone_policy "rsasha1-to-nsec3-wait.kasp" "rsasha1" 1 3600 - set_server "ns3" "10.53.0.3" - set_key_rsasha1_values "KEY1" - set_key_states "KEY1" "omnipresent" "omnipresent" "omnipresent" "omnipresent" "omnipresent" - echo_i "initial check zone ${ZONE}" - check_nsec - - # Zone: nsec3-to-rsasha1.kasp. - set_zone_policy "nsec3-to-rsasha1.kasp" "nsec3" 1 3600 - set_server "ns3" "10.53.0.3" - set_key_rsasha1_values "KEY1" - echo_i "initial check zone ${ZONE}" - check_nsec3 - - # Zone: nsec3-to-rsasha1-ds.kasp. - set_zone_policy "nsec3-to-rsasha1-ds.kasp" "nsec3" 1 3600 - set_server "ns3" "10.53.0.3" - set_key_rsasha1_values "KEY1" - set_key_states "KEY1" "omnipresent" "omnipresent" "omnipresent" "omnipresent" "omnipresent" - echo_i "initial check zone ${ZONE}" - check_nsec3 -fi - -# Zone: nsec3.kasp. -set_zone_policy "nsec3.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-dynamic.kasp. -set_zone_policy "nsec3-dynamic.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-change.kasp. -set_zone_policy "nsec3-change.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Test that NSEC3PARAM TTL is equal to SOA MINIMUM. -n=$((n + 1)) -echo_i "check TTL of NSEC3PARAM in zone $ZONE is equal to SOA MINIMUM ($n)" -ret=0 -dig_with_opts +noquestion "@${SERVER}" "$ZONE" NSEC3PARAM >"dig.out.test$n" || ret=1 -grep "${ZONE}\..*3600.*IN.*NSEC3PARAM" "dig.out.test$n" >/dev/null || ret=1 -test "$ret" -eq 0 || echo_i "failed" -status=$((status + ret)) - -# Update SOA MINIMUM. -cp "${DIR}/template2.db.in" "${DIR}/${ZONE}.db" -rndccmd $SERVER reload $ZONE >rndc.reload.test$n.$ZONE || log_error "failed to call rndc reload $ZONE" -_wait_for_new_soa() { - dig_with_opts +noquestion "@${SERVER}" "$ZONE" SOA >"dig.out.soa.test$n" || return 1 - grep "${ZONE}\..*IN.*SOA.*mname1..*..*20.*20.*.1814400.*900" "dig.out.soa.test$n" >/dev/null || return 1 -} -retry_quiet 10 _wait_for_new_soa || log_error "failed to update SOA record in zone $ZONE" - -# Zone: nsec3-dynamic-change.kasp. -set_zone_policy "nsec3-dynamic-change.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-dynamic-to-inline.kasp. -set_zone_policy "nsec3-dynamic-to-inline.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-inline-to-dynamic.kasp. -set_zone_policy "nsec3-inline-to-dynamic.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-to-nsec.kasp. -set_zone_policy "nsec3-to-nsec.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-to-optout.kasp. -set_zone_policy "nsec3-to-optout.kasp" "nsec3" 1 3600 -set_nsec3param "0" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-from-optout.kasp. -set_zone_policy "nsec3-from-optout.kasp" "optout" 1 3600 -set_nsec3param "1" "0" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-other.kasp. -set_zone_policy "nsec3-other.kasp" "nsec3-other" 1 3600 -set_nsec3param "1" "8" -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec3 - -# Zone: nsec3-xfr-inline.kasp. -# This is a secondary zone, where the primary is signed with NSEC3 but -# the dnssec-policy dictates NSEC. -set_zone_policy "nsec3-xfr-inline.kasp" "nsec" 1 3600 -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec - -# Zone: nsec3-dynamic-update-inline.kasp. -set_zone_policy "nsec3-dynamic-update-inline.kasp" "nsec" 1 3600 -set_key_default_values "KEY1" -echo_i "initial check zone ${ZONE}" -check_nsec - -n=$((n + 1)) -echo_i "dynamic update dnssec-policy zone ${ZONE} with NSEC3 ($n)" -ret=0 -$NSUPDATE >update.out.$ZONE.test$n 2>&1 <