From 78118986ea3454a5c05b62904b10985c3a95b795 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Wed, 26 Jun 2024 20:45:54 +0100 Subject: [PATCH] test: fix OpenSSL version checks As per the original pull request that introduced the OpenSSL version check in `parallel/test-crypto-dh`: ``` Error message change is test-only and uses the right error message for versions >=3.0.12 in 3.0.x and >= 3.1.4 in 3.1.x series. ``` Fix the check so that: - The older message is expected for OpenSSL 3.1.0. - The newer message is expected for OpenSSL from 3.1.4 (e.g. 3.2.x). Refs: https://github.com/nodejs/node/pull/50395 PR-URL: https://github.com/nodejs/node/pull/53503 Refs: https://github.com/nodejs/node/issues/53382 Reviewed-By: Luigi Pinca --- test/parallel/test-crypto-dh.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js index fb580e1b315445..8ae0a002fec094 100644 --- a/test/parallel/test-crypto-dh.js +++ b/test/parallel/test-crypto-dh.js @@ -86,8 +86,9 @@ const crypto = require('crypto'); } { - const hasOpenSSL3WithNewErrorMessage = (common.hasOpenSSL(3, 0, 12) && !common.hasOpenSSL(3, 1, 1)) || - (common.hasOpenSSL(3, 1, 4) && !common.hasOpenSSL(3, 2, 1)); + // Error message was changed in OpenSSL 3.0.x from 3.0.12, and 3.1.x from 3.1.4. + const hasOpenSSL3WithNewErrorMessage = (common.hasOpenSSL(3, 0, 12) && !common.hasOpenSSL(3, 1, 0)) || + (common.hasOpenSSL(3, 1, 4)); assert.throws(() => { dh3.computeSecret(''); }, { message: common.hasOpenSSL3 && !hasOpenSSL3WithNewErrorMessage ?