summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2018-02-15 11:08:27 +0100
committerMyles Borins <mylesborins@google.com>2018-08-16 01:59:08 -0400
commitf534bd889ab0013437087ed49b89f66e5702c387 (patch)
tree4cc16452ef96741ad992555813e5f950684a5db6 /test
parentecf3616f510c867f3eaecf9d0f901f3c96266674 (diff)
downloadnode-new-f534bd889ab0013437087ed49b89f66e5702c387.tar.gz
test: make tls test more rigorous
* 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 <ruben@bridgewater.de> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matheus Marchini <matheus@sthima.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-tls-connect-no-host.js14
1 files 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 d685ba90cc..f6384743ac 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();
+ }));
+}));