Skip to content

Commit 3c29adb

Browse files
bnoordhuisBridgeAR
authored andcommitted
test: make tls test more rigorous
* exit naturally, don't use process.exit() * ensure callbacks are actually called PR-URL: #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>
1 parent 85893af commit 3c29adb

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-tls-connect-no-host.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ if (!common.hasCrypto)
66
common.skip('missing crypto');
77

88
const tls = require('tls');
9-
109
const assert = require('assert');
1110

1211
const cert = fixtures.readSync('test_cert.pem');
@@ -15,19 +14,20 @@ const key = fixtures.readSync('test_key.pem');
1514
// https://github.com/nodejs/node/issues/1489
1615
// tls.connect(options) with no options.host should accept a cert with
1716
// CN:'localhost'
18-
tls.createServer({
17+
const server = tls.createServer({
1918
key,
2019
cert
21-
}).listen(0, function() {
20+
}).listen(0, common.mustCall(function() {
2221
const socket = tls.connect({
2322
port: this.address().port,
2423
ca: cert,
2524
// No host set here. 'localhost' is the default,
2625
// but tls.checkServerIdentity() breaks before the fix with:
2726
// Error: Hostname/IP doesn't match certificate's altnames:
2827
// "Host: undefined. is not cert's CN: localhost"
29-
}, function() {
28+
}, common.mustCall(function() {
3029
assert(socket.authorized);
31-
process.exit();
32-
});
33-
});
30+
socket.destroy();
31+
server.close();
32+
}));
33+
}));

0 commit comments

Comments
 (0)