Skip to content

Commit

Permalink
Add test to check the no-digests quirk
Browse files Browse the repository at this point in the history
Signed-off-by: Simo Sorce <[email protected]>
  • Loading branch information
simo5 committed Jun 12, 2024
1 parent ea0fa5c commit d3cd256
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/openssl.cnf.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pkcs11-module-token-pin = file:@PINFILE@
#pkcs11-module-encode-provider-uri-to-pem
#pkcs11-module-allow-export
#pkcs11-module-load-behavior
#pkcs11-module-block-operations
##QUIRKS
activate = 1

Expand Down
27 changes: 27 additions & 0 deletions tests/tdigest
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,32 @@ OPENSSL_CONF=${OPENSSL_CONF}.early_load

title PARA "Test Digests support"
$CHECKER "${TESTBLDDIR}/tdigests"
echo "PASSED"

# Ensure failure if the digest operations are blocked
sed "s/#pkcs11-module-block-operations/pkcs11-module-block-operations = digest/" \
"${OPENSSL_CONF}" > "${OPENSSL_CONF}.no_digests"
OPENSSL_CONF=${OPENSSL_CONF}.no_digests

title PARA "Test Digests Blocked"
FAIL=0
OUT=$(eval "${TESTBLDDIR}/tdigests" 2>&1) || FAIL=1
if [ $FAIL -ne 0 ]; then
echo "$OUT" | grep "No digest available" || FAIL=2
fi
if [ $FAIL -eq 0 ]; then
echo "Digests test should have failed"
exit 1
fi
if [ $FAIL -eq 1 ]; then
echo "Digest operations failed as expected"
fi
if [ $FAIL -eq 2 ]; then
echo "Digest operations failed but not as expected"
echo "output:\n---"
echo "$OUT"
echo "---"
exit 1
fi

exit 0

0 comments on commit d3cd256

Please sign in to comment.