From 849f5c31c846fa712fa60a84b5d4e9753ff22510 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 15 Feb 2018 11:08:27 +0100 Subject: [PATCH] test: make tls test more rigorous MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * exit naturally, don't use process.exit() * ensure callbacks are actually called PR-URL: https://github.com/nodejs/node/pull/18792 Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Evan Lucas Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Matheus Marchini Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- test/parallel/test-tls-connect-no-host.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js index d685ba90ccdd84..f6384743ac7081 100644 --- a/test/parallel/test-tls-connect-no-host.js +++ b/test/parallel/test-tls-connect-no-host.js @@ -6,7 +6,6 @@ if (!common.hasCrypto) common.skip('missing crypto'); const tls = require('tls'); - const assert = require('assert'); const cert = fixtures.readSync('test_cert.pem'); @@ -15,10 +14,10 @@ const key = fixtures.readSync('test_key.pem'); // https://github.com/nodejs/node/issues/1489 // tls.connect(options) with no options.host should accept a cert with // CN:'localhost' -tls.createServer({ +const server = tls.createServer({ key, cert -}).listen(0, function() { +}).listen(0, common.mustCall(function() { const socket = tls.connect({ port: this.address().port, ca: cert, @@ -26,8 +25,9 @@ tls.createServer({ // but tls.checkServerIdentity() breaks before the fix with: // Error: Hostname/IP doesn't match certificate's altnames: // "Host: undefined. is not cert's CN: localhost" - }, function() { + }, common.mustCall(function() { assert(socket.authorized); - process.exit(); - }); -}); + socket.destroy(); + server.close(); + })); +}));