mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
7535a94c8a
Adds a new `../common/fixtures' module to begin normalizing `test/fixtures` use. Our test code is a bit inconsistent with regards to use of the fixtures directory. Some code uses `path.join()`, some code uses string concats, some other code uses template strings, etc. In mnay cases, significant duplication of code is seen when accessing fixture files, etc. This updates many (but by no means all) of the tests in the test suite to use the new consistent API. There are still many more to update, which would make an excelent Code-n-Learn exercise. PR-URL: https://github.com/nodejs/node/pull/14332 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com>
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
if (common.opensslCli === false)
|
|
common.skip('node compiled without OpenSSL CLI.');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
const spawn = require('child_process').spawn;
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const cert = fixtures.readSync('test_cert.pem');
|
|
const key = fixtures.readSync('test_key.pem');
|
|
const server = tls.createServer({ cert: cert, key: key }, common.mustNotCall());
|
|
const errors = [];
|
|
let stderr = '';
|
|
|
|
server.listen(0, '127.0.0.1', function() {
|
|
const address = `${this.address().address}:${this.address().port}`;
|
|
const args = ['s_client',
|
|
'-ssl3',
|
|
'-connect', address];
|
|
|
|
// for the performance and stability issue in s_client on Windows
|
|
if (common.isWindows)
|
|
args.push('-no_rand_screen');
|
|
|
|
const client = spawn(common.opensslCli, args, { stdio: 'pipe' });
|
|
client.stdout.pipe(process.stdout);
|
|
client.stderr.pipe(process.stderr);
|
|
client.stderr.setEncoding('utf8');
|
|
client.stderr.on('data', (data) => stderr += data);
|
|
|
|
client.once('exit', common.mustCall(function(exitCode) {
|
|
assert.strictEqual(exitCode, 1);
|
|
server.close();
|
|
}));
|
|
});
|
|
|
|
server.on('tlsClientError', (err) => errors.push(err));
|
|
|
|
process.on('exit', function() {
|
|
if (/unknown option -ssl3/.test(stderr)) {
|
|
common.printSkipMessage('`openssl s_client -ssl3` not supported.');
|
|
} else {
|
|
assert.strictEqual(errors.length, 1);
|
|
assert(/:wrong version number/.test(errors[0].message));
|
|
}
|
|
});
|