Skip to content

Commit

Permalink
test: fallback to IPv4 if IPv6 is unavailable
Browse files Browse the repository at this point in the history
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: #47017
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
  • Loading branch information
abmusse authored Mar 11, 2023
1 parent 3591728 commit 5012ab4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/sequential/test-tls-psk-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -23,6 +24,7 @@ const server = spawn(common.opensslCli, [
'-psk_hint', IDENTITY,
'-nocert',
'-rev',
...(useIPv4 ? ['-4'] : []),
], { encoding: 'utf8' });
let serverErr = '';
let serverOut = '';
Expand Down
6 changes: 5 additions & 1 deletion test/sequential/test-tls-securepair-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);

Expand Down

0 comments on commit 5012ab4

Please sign in to comment.