git » chasquid » commit faadae1

tests: Detect buggy dkimpy versions, and skip the test if needed

author Alberto Bertogli
2022-06-19 10:54:55 UTC
committer Alberto Bertogli
2022-06-19 10:56:30 UTC
parent f303e43082adddfedf92152ef5bcc859e479bcee

tests: Detect buggy dkimpy versions, and skip the test if needed

Some dkimpy versions have a bug where it can't parse the keys generated
by its own key generator. That causes the dkimpy test to fail.

See https://bugs.launchpad.net/dkimpy/+bug/1978835 for more details.

This patch adds a workaround which detects the buggy version, and skip
the test if needed.

test/t-19-dkimpy/run.sh +13 -1

diff --git a/test/t-19-dkimpy/run.sh b/test/t-19-dkimpy/run.sh
index e802ab7..48e06f5 100755
--- a/test/t-19-dkimpy/run.sh
+++ b/test/t-19-dkimpy/run.sh
@@ -28,6 +28,16 @@ fi
 generate_certs_for testserver
 ( mkdir -p .dkimcerts; cd .dkimcerts; dknewkey private > log 2>&1 )
 
+# Some dkimpy versions have a bug where it can't parse the keys generated by
+# its own key generator. Detect if that's the case, and if so, skip the test.
+# See https://bugs.launchpad.net/dkimpy/+bug/1978835.
+if ! /usr/bin/dkimsign \
+	testselector1 testserver .dkimcerts/private.key \
+	< content 2>&1 | grep -q "DKIM-Signature:"
+then
+	skip "buggy dkimpy version"
+fi
+
 add_user user@testserver secretpassword
 add_user someone@testserver secretpassword
 
@@ -40,7 +50,9 @@ wait_until_ready 1025
 run_msmtp someone@testserver < content
 wait_for_file .mail/someone@testserver
 mail_diff content .mail/someone@testserver
-grep -q "DKIM-Signature:" .mail/someone@testserver
+if ! grep -q "DKIM-Signature:" .mail/someone@testserver; then
+	fail "mail not signed, DKIM-Signature header missing"
+fi
 
 # Verify the signature manually, just in case.
 # NOTE: This is using driusan/dkim instead of dkimpy, because dkimpy can't be