From 9f521f456e88fa40a000b19f6c5fb2ef7ea0da82 Mon Sep 17 00:00:00 2001 From: Richard Lau Date: Mon, 10 Jun 2024 18:43:36 +0100 Subject: [PATCH] test: update tests for OpenSSL 3.0.14 Starting from OpenSSL 3.0.14, 3.1.6, 3.2.2, and 3.3.1, OpenSSL was fixed to return an error reason string for bad/unknown application protocols. Update tests to handle both the old `ECONNRESET` error on older versions of OpenSSL and the new `ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL` on newer versions of OpenSSL. Refs: https://github.com/openssl/openssl/pull/24338 PR-URL: https://github.com/nodejs/node/pull/53373 Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/parallel/test-tls-alpn-server-client.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js index 522dd34ad21567..3f0ee2a0f93c56 100644 --- a/test/parallel/test-tls-alpn-server-client.js +++ b/test/parallel/test-tls-alpn-server-client.js @@ -195,7 +195,8 @@ function TestALPNCallback() { // Callback picks 2nd preference => undefined => ALPN rejected: assert.strictEqual(results[1].server, undefined); - assert.strictEqual(results[1].client.error.code, 'ECONNRESET'); + const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL']; + assert.ok(allowedErrors.includes(results[1].client.error.code), `'${results[1].client.error.code}' was not one of ${allowedErrors}.`); TestBadALPNCallback(); }); @@ -218,7 +219,8 @@ function TestBadALPNCallback() { runTest(clientsOptions, serverOptions, function(results) { // Callback returns 'http/5' => doesn't match client ALPN => error & reset assert.strictEqual(results[0].server, undefined); - assert.strictEqual(results[0].client.error.code, 'ECONNRESET'); + const allowedErrors = ['ECONNRESET', 'ERR_SSL_TLSV1_ALERT_NO_APPLICATION_PROTOCOL']; + assert.ok(allowedErrors.includes(results[0].client.error.code), `'${results[0].client.error.code}' was not one of ${allowedErrors}.`); TestALPNOptionsCallback(); });