Skip to content

Commit

Permalink
test: Fallback to IPv4 when 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 check for 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_/
  • Loading branch information
abmusse committed Mar 8, 2023
1 parent b8ef1b4 commit 753326f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/sequential/test-tls-psk-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ if (!common.hasCrypto)
if (!common.opensslCli)
common.skip('missing openssl cli');

const useIPv4 = common.hasIPv6 ? false : true;

const assert = require('assert');
const tls = require('tls');
const net = require('net');
Expand All @@ -23,6 +25,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 @@ -32,6 +32,8 @@ if (!common.hasCrypto)
if (common.isWindows)
common.skip('test does not work on Windows'); // ...but it should!

const useIPv4 = common.hasIPv6 ? false : true;

const net = require('net');
const assert = require('assert');
const fixtures = require('../common/fixtures');
Expand Down Expand Up @@ -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 753326f

Please sign in to comment.