Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: simplify test-tls-ecdh-auto #46911

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 8 additions & 26 deletions test/parallel/test-tls-ecdh-auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (!common.opensslCli)

const assert = require('assert');
const tls = require('tls');
const spawn = require('child_process').spawn;
const { execFile } = require('child_process');
const fixtures = require('../common/fixtures');

function loadPEM(n) {
Expand All @@ -29,33 +29,15 @@ const options = {

const reply = 'I AM THE WALRUS'; // Something recognizable

const server = tls.createServer(options, function(conn) {
const server = tls.createServer(options, (conn) => {
conn.end(reply);
});

let gotReply = false;

server.listen(0, function() {
}).listen(0, common.mustCall(() => {
const args = ['s_client',
'-cipher', `${options.ciphers}`,
'-connect', `127.0.0.1:${this.address().port}`];

const client = spawn(common.opensslCli, args);
'-connect', `127.0.0.1:${server.address().port}`];

client.stdout.on('data', function(data) {
const message = data.toString();
if (message.includes(reply))
gotReply = true;
});

client.on('exit', function(code) {
assert.strictEqual(code, 0);
execFile(common.opensslCli, args, common.mustSucceed((stdout) => {
assert(stdout.includes(reply));
server.close();
});

client.on('error', assert.ifError);
});

process.on('exit', function() {
assert.ok(gotReply);
});
}));
}));