]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make max search depth variable in kasp system test
authorMatthijs Mekking <matthijs@isc.org>
Fri, 26 Jan 2024 10:57:25 +0000 (11:57 +0100)
committerMatthijs Mekking <matthijs@isc.org>
Mon, 29 Jan 2024 07:45:34 +0000 (08:45 +0100)
In the second test we are looking for key files and extract the key
id numbers. Because keys can be in different directories, we needed
to change the maxdepth when searching for keys.

For the second kasp system test, check that 'dnssec-keygen -k' (default
policy) creates valid files, the 'get_keyids' returned more than one
keytag, namely the ones that are inside the keys/ directory, that were
created for the predecessor test, check that 'dnssec-keygen -k'
(configuredd policy) creates valid files.

This caused the system test to spew out errors that key files were
missing (we were looking for key files in the current directory, but
when looking for key id numbers we included the keys/ directory). It
could also cause the next test to fail, check that 'dnssec-settime' by
default does not edit key state file, because the STATE_FILE environment
variable was overwritten with the key file path of one of the keys that
were created with the configured policy.

We fix this by adjusting the maxdepth for the test in question. Other
tests don't need adjusting because they use unique zone names.

bin/tests/system/kasp.sh
bin/tests/system/kasp/tests.sh

index bc8cc9e0f549436adb7e1c7c7df9cf984cfa5863..4177f2080277c5bb824bce3bdb26bda6dd2cdb37 100644 (file)
@@ -34,6 +34,8 @@ SHA256="R16NojROxtxH/xbDl//ehDsHm5DjWTQ2YXV+hGC2iBY="
 VIEW1="YPfMoAk6h+3iN8MDRQC004iSNHY="
 VIEW2="4xILSZQnuO1UKubXHkYUsvBRPu8="
 VIEW3="C1Azf+gGPMmxrUg/WQINP6eV9Y0="
+MINDEPTH=1
+MAXDEPTH=3
 
 ###############################################################################
 # Key properties                                                              #
@@ -179,7 +181,7 @@ get_keyids() {
   _zone=$2
   _regex="K${_zone}.+*+*.key"
 
-  find "${_dir}" -mindepth 1 -maxdepth 3 -name "${_regex}" | sed "s,.*/K${_zone}.+\([0-9]\{3\}\)+\([0-9]\{5\}\).key,\2,"
+  find "${_dir}" -mindepth $MINDEPTH -maxdepth $MAXDEPTH -name "${_regex}" | sed "s,.*/K${_zone}.+\([0-9]\{3\}\)+\([0-9]\{5\}\).key,\2,"
 }
 
 # By default log errors and don't quit immediately.
index 3c2484cc4d1bebc0142f10d17e0a975af733f354..c95c607a5fa577f3f91a753bdf7bc305a4d1c8c9 100644 (file)
@@ -142,7 +142,11 @@ key_clear "KEY4"
 $KEYGEN -G -k "$POLICY" "$ZONE" >"keygen.out.$POLICY.test$n" 2>/dev/null || ret=1
 lines=$(wc -l <"keygen.out.$POLICY.test$n")
 test "$lines" -eq $NUM_KEYS || log_error "wrong number of keys created for policy default: $lines"
+# Temporarily adjust max search depth for this test
+MAXDEPTH=1
 ids=$(get_keyids "$DIR" "$ZONE")
+MAXDEPTH=3
+echo_i "found in dir $DIR for zone $ZONE the following keytags: $ids"
 for id in $ids; do
   check_key "KEY1" "$id"
   test "$ret" -eq 0 && key_save KEY1