1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

test: Fix generate_cert cache age logic

The generate_cert cache has a bug because it uses the directory's age,
which won't necessarily change, and it was always re-generating
certificates after 10m.

This patch fixes the bug by checking the age of the private key file
instead of the directory.
This commit is contained in:
Alberto Bertogli
2024-03-09 10:39:17 +00:00
parent 3be7cd5160
commit 1208ea1082

View File

@@ -195,11 +195,10 @@ function generate_certs_for() {
# Generating certs is takes time and slows the tests down, so we keep
# a little cache that is common to all tests.
CACHEDIR="${TBASE}/../.generate_certs_cache"
mkdir -p "${CACHEDIR}"
mkdir -p "${CACHEDIR}/$1/"
touch -d "10 minutes ago" "${CACHEDIR}/.reference"
if [ "${CACHEDIR}/$1/" -ot "${CACHEDIR}/.reference" ]; then
if [ "${CACHEDIR}/$1/privkey.pem" -ot "${CACHEDIR}/.reference" ]; then
# Cache miss (either was not there, or was too old).
mkdir -p "${CACHEDIR}/$1/"
(
cd "${CACHEDIR}/$1/" || exit 1
generate_cert -ca -validfor=1h -host="$1"