From: Matthijs Mekking Date: Fri, 26 Jan 2024 10:57:25 +0000 (+0100) Subject: Make max search depth variable in kasp system test X-Git-Tag: v9.19.22~68^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b14c0546c152f76760d0ce0942fbab31897ec325;p=thirdparty%2Fbind9.git Make max search depth variable in kasp system test 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. --- diff --git a/bin/tests/system/kasp.sh b/bin/tests/system/kasp.sh index bc8cc9e0f54..4177f208027 100644 --- a/bin/tests/system/kasp.sh +++ b/bin/tests/system/kasp.sh @@ -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. diff --git a/bin/tests/system/kasp/tests.sh b/bin/tests/system/kasp/tests.sh index 3c2484cc4d1..c95c607a5fa 100644 --- a/bin/tests/system/kasp/tests.sh +++ b/bin/tests/system/kasp/tests.sh @@ -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