Skip to content

Commit

Permalink
test: deflake test-tls-passphrase
Browse files Browse the repository at this point in the history
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 20, 2019
1 parent 82eeadb commit 6bafd35
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions test/parallel/test-tls-passphrase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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({
Expand All @@ -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/;
Expand Down

0 comments on commit 6bafd35

Please sign in to comment.