mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
28e9a022df
Currently there are many instances where assert.fail is directly passed to a callback for error handling. Unfortunately this will swallow the error as it is the third argument of assert.fail that sets the message not the first. This commit adds a new function to test/common.js that simply wraps assert.fail and calls it with the provided message. Tip of the hat to @trott for pointing me in the direction of this. PR-URL: https://github.com/nodejs/node/pull/3453 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
'use strict';
|
|
var common = require('../common');
|
|
var assert = require('assert');
|
|
|
|
if (!common.hasCrypto) {
|
|
console.log('1..0 # Skipped: missing crypto');
|
|
return;
|
|
}
|
|
var tls = require('tls');
|
|
|
|
var fs = require('fs');
|
|
var spawn = require('child_process').spawn;
|
|
|
|
if (common.opensslCli === false) {
|
|
console.log('1..0 # Skipped: node compiled without OpenSSL CLI.');
|
|
return;
|
|
}
|
|
|
|
var cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem');
|
|
var key = fs.readFileSync(common.fixturesDir + '/test_key.pem');
|
|
var server = tls.createServer({ cert: cert, key: key }, common.fail);
|
|
|
|
server.listen(common.PORT, '127.0.0.1', function() {
|
|
var address = this.address().address + ':' + this.address().port;
|
|
var args = ['s_client',
|
|
'-no_ssl2',
|
|
'-ssl3',
|
|
'-no_tls1',
|
|
'-no_tls1_1',
|
|
'-no_tls1_2',
|
|
'-connect', address];
|
|
|
|
// for the performance and stability issue in s_client on Windows
|
|
if (common.isWindows)
|
|
args.push('-no_rand_screen');
|
|
|
|
var client = spawn(common.opensslCli, args, { stdio: 'inherit' });
|
|
client.once('exit', common.mustCall(function(exitCode) {
|
|
assert.equal(exitCode, 1);
|
|
server.close();
|
|
}));
|
|
});
|
|
|
|
server.once('clientError', common.mustCall(function(err, conn) {
|
|
assert(/:wrong version number/.test(err.message));
|
|
}));
|