Skip to content
Permalink
Browse files

test: deflake test-tls-passphrase

Move `socket.end()` to client.

Fixes: #28111
Refs: #27569

PR-URL: #29134
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
lpinca authored and targos committed Aug 15, 2019
1 parent 82eeadb commit 6bafd353697a282aa88b8774967277c56bdc0150
Showing with 26 additions and 24 deletions.
  1. +26 −24 test/parallel/test-tls-passphrase.js
@@ -37,15 +37,17 @@ 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',
cert: cert,
ca: [cert],
requestCert: true,
rejectUnauthorized: true
}, function(s) {
s.end();
});

server.listen(0, common.mustCall(function() {
@@ -56,22 +58,22 @@ 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,
key: rawKey,
passphrase: 'ignored',
cert: cert,
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

// Buffer[]
tls.connect({
@@ -80,22 +82,22 @@ 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,
key: [rawKey],
passphrase: 'ignored',
cert: [cert],
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

// string
tls.connect({
@@ -104,22 +106,22 @@ 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,
key: rawKey.toString(),
passphrase: 'ignored',
cert: cert.toString(),
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

// String[]
tls.connect({
@@ -128,97 +130,97 @@ 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,
key: [rawKey.toString()],
passphrase: 'ignored',
cert: [cert.toString()],
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

// Object[]
tls.connect({
port: this.address().port,
key: [{ pem: passKey, passphrase: 'password' }],
cert: cert,
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

tls.connect({
port: this.address().port,
key: [{ pem: passKey, passphrase: 'password' }],
passphrase: 'ignored',
cert: cert,
rejectUnauthorized: false
}, common.mustCall());
}, onSecureConnect());

tls.connect({
port: this.address().port,
key: [{ pem: passKey }],
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,
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,
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/;

0 comments on commit 6bafd35

Please sign in to comment.
You can’t perform that action at this time.