]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add kasp tests dyn update zone
authorMatthijs Mekking <matthijs@isc.org>
Thu, 9 Apr 2020 06:46:37 +0000 (08:46 +0200)
committerMatthijs Mekking <matthijs@isc.org>
Thu, 16 Apr 2020 12:22:47 +0000 (14:22 +0200)
Add two tests that checks that dynamic zones
can be updated and will be signed appropriately.
One zone covers an update with freeze/thaw, the
other covers an update through nsupdate.

bin/tests/system/kasp/tests.sh

index fee431d3eebe6d0af6f63552135d0d17d0ea0eca..69fd81ea2718f42070dbd297c717ab0356fb2890 100644 (file)
@@ -1048,36 +1048,28 @@ dnssec_verify
 
 # Update zone.
 n=$((n+1))
-echo_i "check that we can update unsigned zone file and new record gets signed for zone ${ZONE} ($n)"
+echo_i "modify unsigned zone file and check that new record is signed for zone ${ZONE} ($n)"
 ret=0
 cp "${DIR}/template2.db.in" "${DIR}/${ZONE}.db"
 rndccmd 10.53.0.3 reload "$ZONE" > /dev/null || log_error "rndc reload zone ${ZONE} failed"
-_log=0
-i=0
-while [ $i -lt 5 ]
-do
-       ret=0
 
-       dig_with_opts "a.${ZONE}" "@${SERVER}" A > "dig.out.$DIR.test$n.a" || log_error "dig a.${ZONE} A failed"
-       grep "status: NOERROR" "dig.out.$DIR.test$n.a" > /dev/null || log_error "mismatch status in DNS response"
-       grep "a.${ZONE}\..*${DEFAULT_TTL}.*IN.*A.*10\.0\.0\.11" "dig.out.$DIR.test$n.a" > /dev/null || log_error "missing a.${ZONE} A record in response"
+update_is_signed() {
+       dig_with_opts "a.${ZONE}" "@${SERVER}" A > "dig.out.$DIR.test$n.a" || return 1
+       grep "status: NOERROR" "dig.out.$DIR.test$n.a" > /dev/null || return 1
+       grep "a.${ZONE}\..*${DEFAULT_TTL}.*IN.*A.*10\.0\.0\.11" "dig.out.$DIR.test$n.a" > /dev/null || return 1
        lines=$(get_keys_which_signed A "dig.out.$DIR.test$n.a" | wc -l)
-       test "$lines" -eq 1 || log_error "bad number ($lines) of RRSIG records in DNS response"
-       get_keys_which_signed A "dig.out.$DIR.test$n.a" | grep "^${KEY_ID}$" > /dev/null || log_error "A RRset not signed with key ${KEY_ID}"
+       test "$lines" -eq 1 || return 1
+       get_keys_which_signed A "dig.out.$DIR.test$n.a" | grep "^${KEY_ID}$" > /dev/null || return 1
 
-       dig_with_opts "d.${ZONE}" "@${SERVER}" A > "dig.out.$DIR.test$n".d || log_error "dig d.${ZONE} A failed"
-       grep "status: NOERROR" "dig.out.$DIR.test$n".d > /dev/null || log_error "mismatch status in DNS response"
-       grep "d.${ZONE}\..*${DEFAULT_TTL}.*IN.*A.*10\.0\.0\.4" "dig.out.$DIR.test$n".d > /dev/null || log_error "missing d.${ZONE} A record in response"
+       dig_with_opts "d.${ZONE}" "@${SERVER}" A > "dig.out.$DIR.test$n".d || return 1
+       grep "status: NOERROR" "dig.out.$DIR.test$n".d > /dev/null || return 1
+       grep "d.${ZONE}\..*${DEFAULT_TTL}.*IN.*A.*10\.0\.0\.4" "dig.out.$DIR.test$n".d > /dev/null || return 1
        lines=$(get_keys_which_signed A "dig.out.$DIR.test$n".d | wc -l)
-       test "$lines" -eq 1 || log_error "bad number ($lines) of RRSIG records in DNS response"
-       get_keys_which_signed A "dig.out.$DIR.test$n".d | grep "^${KEY_ID}$" > /dev/null || log_error "A RRset not signed with key ${KEY_ID}"
+       test "$lines" -eq 1 || return 1
+       get_keys_which_signed A "dig.out.$DIR.test$n".d | grep "^${KEY_ID}$" > /dev/null || return 1
+}
 
-       i=$((i+1))
-       if [ $ret = 0 ]; then break; fi
-       echo_i "waiting ... ($i)"
-       sleep 1
-done
-_log=1
+retry_quiet 10 update_is_signed || ret=1
 test "$ret" -eq 0 || echo_i "failed"
 status=$((status+ret))
 
@@ -1093,6 +1085,24 @@ check_apex
 check_subdomain
 dnssec_verify
 
+# Update zone with nsupdate.
+n=$((n+1))
+echo_i "nsupdate zone and check that new record is signed for zone ${ZONE} ($n)"
+ret=0
+(
+echo zone ${ZONE}
+echo server 10.53.0.3 "$PORT"
+echo update del "a.${ZONE}" 300 A 10.0.0.1
+echo update add "a.${ZONE}" 300 A 10.0.0.11
+echo update add "d.${ZONE}" 300 A 10.0.0.4
+echo send
+) | $NSUPDATE
+
+retry_quiet 10 update_is_signed || ret=1
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status+ret))
+
+
 #
 # Zone: dynamic-inline-signing.kasp
 #
@@ -1105,6 +1115,19 @@ check_apex
 check_subdomain
 dnssec_verify
 
+# Update zone with freeze/thaw.
+n=$((n+1))
+echo_i "modify unsigned zone file and check that new record is signed for zone ${ZONE} ($n)"
+ret=0
+rndccmd 10.53.0.3 freeze "$ZONE" > /dev/null || log_error "rndc freeze zone ${ZONE} failed"
+sleep 1
+cp "${DIR}/template2.db.in" "${DIR}/${ZONE}.db"
+rndccmd 10.53.0.3 thaw "$ZONE" > /dev/null || log_error "rndc thaw zone ${ZONE} failed"
+
+retry_quiet 10 update_is_signed || ret=1
+test "$ret" -eq 0 || echo_i "failed"
+status=$((status+ret))
+
 #
 # Zone: inline-signing.kasp
 #