From 5012ab4e8693c7aa32fa7d6a989e48ebf298b233 Mon Sep 17 00:00:00 2001 From: Abdirahim Musse <33973272+abmusse@users.noreply.github.com> Date: Sat, 11 Mar 2023 00:26:25 -0600 Subject: [PATCH] test: fallback to IPv4 if IPv6 is unavailable openssl seems to default to use IPv6. This change adds a checks if IPv6 is unavailable and uses IPv4 instead. On the Node.js CI IBM i build system IPv6 is currently disabled. This change should resolve the following test case failures: - https://ci.nodejs.org/job/node-test-commit-ibmi/nodes=ibmi73-ppc64/1085/testReport/(root)/test/sequential_test_tls_psk_client_/ - https://ci.nodejs.org/job/node-test-commit-ibmi/nodes=ibmi73-ppc64/1085/testReport/(root)/test/sequential_test_tls_securepair_client_/ PR-URL: https://github.com/nodejs/node/pull/47017 Reviewed-By: Luigi Pinca Reviewed-By: Richard Lau Reviewed-By: Yagiz Nizipli --- test/sequential/test-tls-psk-client.js | 2 ++ test/sequential/test-tls-securepair-client.js | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/sequential/test-tls-psk-client.js b/test/sequential/test-tls-psk-client.js index cb15acd01fcccb..ddebc8f8cc9807 100644 --- a/test/sequential/test-tls-psk-client.js +++ b/test/sequential/test-tls-psk-client.js @@ -14,6 +14,7 @@ const { spawn } = require('child_process'); const CIPHERS = 'PSK+HIGH'; const KEY = 'd731ef57be09e5204f0b205b60627028'; const IDENTITY = 'Client_identity'; // Hardcoded by `openssl s_server` +const useIPv4 = !common.hasIPv6; const server = spawn(common.opensslCli, [ 's_server', @@ -23,6 +24,7 @@ const server = spawn(common.opensslCli, [ '-psk_hint', IDENTITY, '-nocert', '-rev', + ...(useIPv4 ? ['-4'] : []), ], { encoding: 'utf8' }); let serverErr = ''; let serverOut = ''; diff --git a/test/sequential/test-tls-securepair-client.js b/test/sequential/test-tls-securepair-client.js index c9215c43ad6ddb..f3ca42ad6edfb0 100644 --- a/test/sequential/test-tls-securepair-client.js +++ b/test/sequential/test-tls-securepair-client.js @@ -38,6 +38,8 @@ const fixtures = require('../common/fixtures'); const tls = require('tls'); const spawn = require('child_process').spawn; +const useIPv4 = !common.hasIPv6; + test1(); // simple/test-tls-securepair-client @@ -64,7 +66,9 @@ function test(keyPath, certPath, check, next) { const server = spawn(common.opensslCli, ['s_server', '-accept', 0, '-cert', fixtures.path(certPath), - '-key', fixtures.path(keyPath)]); + '-key', fixtures.path(keyPath), + ...(useIPv4 ? ['-4'] : []), + ]); server.stdout.pipe(process.stdout); server.stderr.pipe(process.stdout);