From 6bafd353697a282aa88b8774967277c56bdc0150 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 15 Aug 2019 12:04:42 +0200 Subject: [PATCH] test: deflake test-tls-passphrase Move `socket.end()` to client. Fixes: https://github.com/nodejs/node/issues/28111 Refs: https://github.com/nodejs/node/pull/27569 PR-URL: https://github.com/nodejs/node/pull/29134 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Sam Roberts Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-tls-passphrase.js | 50 +++++++++++++++------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/test/parallel/test-tls-passphrase.js b/test/parallel/test-tls-passphrase.js index e6b57b243f684b..c3a99c3eb34833 100644 --- a/test/parallel/test-tls-passphrase.js +++ b/test/parallel/test-tls-passphrase.js @@ -37,6 +37,10 @@ assert(Buffer.isBuffer(cert)); assert.strictEqual(typeof passKey.toString(), 'string'); assert.strictEqual(typeof cert.toString(), 'string'); +function onSecureConnect() { + return common.mustCall(function() { this.end(); }); +} + const server = tls.Server({ key: passKey, passphrase: 'password', @@ -44,8 +48,6 @@ const server = tls.Server({ ca: [cert], requestCert: true, rejectUnauthorized: true -}, function(s) { - s.end(); }); server.listen(0, common.mustCall(function() { @@ -56,14 +58,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'password', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: rawKey, cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -71,7 +73,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); // Buffer[] tls.connect({ @@ -80,14 +82,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'password', cert: [cert], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [rawKey], cert: [cert], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -95,7 +97,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: [cert], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); // string tls.connect({ @@ -104,14 +106,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'password', cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: rawKey.toString(), cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -119,7 +121,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert.toString(), rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); // String[] tls.connect({ @@ -128,14 +130,14 @@ server.listen(0, common.mustCall(function() { passphrase: 'password', cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [rawKey.toString()], cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -143,7 +145,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: [cert.toString()], rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); // Object[] tls.connect({ @@ -151,7 +153,7 @@ server.listen(0, common.mustCall(function() { key: [{ pem: passKey, passphrase: 'password' }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -159,7 +161,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -167,28 +169,28 @@ server.listen(0, common.mustCall(function() { passphrase: 'password', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [{ pem: passKey.toString(), passphrase: 'password' }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [{ pem: rawKey, passphrase: 'ignored' }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [{ pem: rawKey.toString(), passphrase: 'ignored' }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -196,7 +198,7 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, @@ -204,21 +206,21 @@ server.listen(0, common.mustCall(function() { passphrase: 'ignored', cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [{ pem: rawKey }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); tls.connect({ port: this.address().port, key: [{ pem: rawKey.toString() }], cert: cert, rejectUnauthorized: false - }, common.mustCall()); + }, onSecureConnect()); })).unref(); const errMessagePassword = /bad decrypt/;