test: begin normalizing fixtures use
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>
This commit is contained in:
parent
7192e913f7
commit
7535a94c8a
@ -374,6 +374,37 @@ Decrements the `Countdown` counter.
|
|||||||
Specifies the remaining number of times `Countdown.prototype.dec()` must be
|
Specifies the remaining number of times `Countdown.prototype.dec()` must be
|
||||||
called before the callback is invoked.
|
called before the callback is invoked.
|
||||||
|
|
||||||
|
## Fixtures Module
|
||||||
|
|
||||||
|
The `common/fixtures` module provides convenience methods for working with
|
||||||
|
files in the `test/fixtures` directory.
|
||||||
|
|
||||||
|
### fixtures.fixturesDir
|
||||||
|
|
||||||
|
* [<String>]
|
||||||
|
|
||||||
|
The absolute path to the `test/fixtures/` directory.
|
||||||
|
|
||||||
|
### fixtures.path(...args)
|
||||||
|
|
||||||
|
* `...args` [<String>]
|
||||||
|
|
||||||
|
Returns the result of `path.join(fixtures.fixturesDir, ...args)`.
|
||||||
|
|
||||||
|
### fixtures.readSync(args[, enc])
|
||||||
|
|
||||||
|
* `args` [<String>] | [<Array>]
|
||||||
|
|
||||||
|
Returns the result of
|
||||||
|
`fs.readFileSync(path.join(fixtures.fixturesDir, ...args), 'enc')`.
|
||||||
|
|
||||||
|
### fixtures.readKey(arg[, enc])
|
||||||
|
|
||||||
|
* `arg` [<String>]
|
||||||
|
|
||||||
|
Returns the result of
|
||||||
|
`fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`.
|
||||||
|
|
||||||
## WPT Module
|
## WPT Module
|
||||||
|
|
||||||
The wpt.js module is a port of parts of
|
The wpt.js module is a port of parts of
|
||||||
|
28
test/common/fixtures.js
Normal file
28
test/common/fixtures.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/* eslint-disable required-modules */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
const fixturesDir = path.join(__dirname, '..', 'fixtures');
|
||||||
|
|
||||||
|
function fixturesPath(...args) {
|
||||||
|
return path.join(fixturesDir, ...args);
|
||||||
|
}
|
||||||
|
|
||||||
|
function readFixtureSync(args, enc) {
|
||||||
|
if (Array.isArray(args))
|
||||||
|
return fs.readFileSync(fixturesPath(...args), enc);
|
||||||
|
return fs.readFileSync(fixturesPath(args), enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
function readFixtureKey(name, enc) {
|
||||||
|
return fs.readFileSync(fixturesPath('keys', name), enc);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
fixturesDir,
|
||||||
|
path: fixturesPath,
|
||||||
|
readSync: readFixtureSync,
|
||||||
|
readKey: readFixtureKey
|
||||||
|
};
|
@ -29,13 +29,15 @@ const { exec, execSync, spawn, spawnSync } = require('child_process');
|
|||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const Timer = process.binding('timer_wrap').Timer;
|
const Timer = process.binding('timer_wrap').Timer;
|
||||||
|
const { fixturesDir } = require('./fixtures');
|
||||||
|
|
||||||
const testRoot = process.env.NODE_TEST_DIR ?
|
const testRoot = process.env.NODE_TEST_DIR ?
|
||||||
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
|
fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..');
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
exports.fixturesDir = path.join(__dirname, '..', 'fixtures');
|
exports.fixturesDir = fixturesDir;
|
||||||
|
|
||||||
exports.tmpDirName = 'tmp';
|
exports.tmpDirName = 'tmp';
|
||||||
// PORT should match the definition in test/testpy/__init__.py.
|
// PORT should match the definition in test/testpy/__init__.py.
|
||||||
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
|
exports.PORT = +process.env.NODE_COMMON_PORT || 12346;
|
||||||
|
@ -8,12 +8,12 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`),
|
cert: fixtures.readKey('agent1-cert.pem'),
|
||||||
ca: fs.readFileSync(`${common.fixturesDir}/keys/ca1-cert.pem`)
|
ca: fixtures.readKey('ca1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = https.createServer(serverOptions, common.mustCall((req, res) => {
|
const server = https.createServer(serverOptions, common.mustCall((req, res) => {
|
||||||
|
@ -5,6 +5,7 @@ const assert = require('assert');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const providers = Object.assign({}, process.binding('async_wrap').Providers);
|
const providers = Object.assign({}, process.binding('async_wrap').Providers);
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Make sure that all Providers are tested.
|
// Make sure that all Providers are tested.
|
||||||
{
|
{
|
||||||
@ -218,9 +219,10 @@ if (common.hasCrypto) {
|
|||||||
const TCP = process.binding('tcp_wrap').TCP;
|
const TCP = process.binding('tcp_wrap').TCP;
|
||||||
const tcp = new TCP();
|
const tcp = new TCP();
|
||||||
|
|
||||||
const ca = fs.readFileSync(common.fixturesDir + '/test_ca.pem', 'ascii');
|
const ca = fixtures.readSync('test_ca.pem', 'ascii');
|
||||||
const cert = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii');
|
const cert = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
const key = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii');
|
const key = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
|
|
||||||
const credentials = require('tls').createSecureContext({ ca, cert, key });
|
const credentials = require('tls').createSecureContext({ ca, cert, key });
|
||||||
|
|
||||||
// TLSWrap is exposed, but needs to be instantiated via tls_wrap.wrap().
|
// TLSWrap is exposed, but needs to be instantiated via tls_wrap.wrap().
|
||||||
|
@ -20,13 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const childPath = path.join(common.fixturesDir,
|
const childPath = fixtures.path('parent-process-nonpersistent.js');
|
||||||
'parent-process-nonpersistent.js');
|
|
||||||
let persistentPid = -1;
|
let persistentPid = -1;
|
||||||
|
|
||||||
const child = spawn(process.execPath, [ childPath ]);
|
const child = spawn(process.execPath, [ childPath ]);
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const execFile = require('child_process').execFile;
|
const execFile = require('child_process').execFile;
|
||||||
const path = require('path');
|
|
||||||
const uv = process.binding('uv');
|
const uv = process.binding('uv');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const fixture = path.join(common.fixturesDir, 'exit.js');
|
const fixture = fixtures.path('exit.js');
|
||||||
|
|
||||||
{
|
{
|
||||||
execFile(
|
execFile(
|
||||||
|
@ -23,9 +23,9 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const exitScript = path.join(common.fixturesDir, 'exit.js');
|
const exitScript = fixtures.path('exit.js');
|
||||||
const exitChild = spawn(process.argv[0], [exitScript, 23]);
|
const exitChild = spawn(process.argv[0], [exitScript, 23]);
|
||||||
exitChild.on('exit', common.mustCall(function(code, signal) {
|
exitChild.on('exit', common.mustCall(function(code, signal) {
|
||||||
assert.strictEqual(code, 23);
|
assert.strictEqual(code, 23);
|
||||||
@ -33,8 +33,7 @@ exitChild.on('exit', common.mustCall(function(code, signal) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
const errorScript = path.join(common.fixturesDir,
|
const errorScript = fixtures.path('child_process_should_emit_error.js');
|
||||||
'child_process_should_emit_error.js');
|
|
||||||
const errorChild = spawn(process.argv[0], [errorScript]);
|
const errorChild = spawn(process.argv[0], [errorScript]);
|
||||||
errorChild.on('exit', common.mustCall(function(code, signal) {
|
errorChild.on('exit', common.mustCall(function(code, signal) {
|
||||||
assert.ok(code !== 0);
|
assert.ok(code !== 0);
|
||||||
|
@ -23,8 +23,9 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const cp = fork(`${common.fixturesDir}/child-process-message-and-exit.js`);
|
const cp = fork(fixtures.path('child-process-message-and-exit.js'));
|
||||||
|
|
||||||
let gotMessage = false;
|
let gotMessage = false;
|
||||||
let gotExit = false;
|
let gotExit = false;
|
||||||
|
@ -7,8 +7,9 @@ const common = require('../common');
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const childScript = `${common.fixturesDir}/child-process-spawn-node`;
|
const childScript = fixtures.path('child-process-spawn-node');
|
||||||
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
|
const errorRegexp = /^TypeError: Incorrect value of stdio option:/;
|
||||||
const malFormedOpts = { stdio: '33' };
|
const malFormedOpts = { stdio: '33' };
|
||||||
const payload = { hello: 'world' };
|
const payload = { hello: 'world' };
|
||||||
|
@ -24,8 +24,9 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fork = require('child_process').fork;
|
const fork = require('child_process').fork;
|
||||||
const args = ['foo', 'bar'];
|
const args = ['foo', 'bar'];
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const n = fork(`${common.fixturesDir}/child-process-spawn-node.js`, args);
|
const n = fork(fixtures.path('child-process-spawn-node.js'), args);
|
||||||
|
|
||||||
assert.strictEqual(n.channel, n._channel);
|
assert.strictEqual(n.channel, n._channel);
|
||||||
assert.deepStrictEqual(args, ['foo', 'bar']);
|
assert.deepStrictEqual(args, ['foo', 'bar']);
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
child_process.fork(`${common.fixturesDir}/empty.js`); // should not hang
|
child_process.fork(fixtures.path('empty.js')); // should not hang
|
||||||
|
@ -21,14 +21,13 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const spawn = require('child_process').spawn;
|
const { spawn } = require('child_process');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const path = require('path');
|
const sub = fixtures.path('echo.js');
|
||||||
|
|
||||||
const sub = path.join(common.fixturesDir, 'echo.js');
|
|
||||||
|
|
||||||
let gotHelloWorld = false;
|
let gotHelloWorld = false;
|
||||||
let gotEcho = false;
|
let gotEcho = false;
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
const fixture = path.join(common.fixturesDir, 'empty.js');
|
|
||||||
|
const fixture = fixtures.path('empty.js');
|
||||||
const child = cp.fork(fixture);
|
const child = cp.fork(fixture);
|
||||||
|
|
||||||
child.on('close', common.mustCall((code, signal) => {
|
child.on('close', common.mustCall((code, signal) => {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const { fork, spawn } = require('child_process');
|
const { fork, spawn } = require('child_process');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const emptyFile = path.join(common.fixturesDir, 'empty.js');
|
const emptyFile = fixtures.path('empty.js');
|
||||||
|
|
||||||
const n = fork(emptyFile);
|
const n = fork(emptyFile);
|
||||||
|
|
||||||
|
@ -22,17 +22,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const child_process = require('child_process');
|
const { spawn, fork, execFile } = require('child_process');
|
||||||
const spawn = child_process.spawn;
|
const fixtures = require('../common/fixtures');
|
||||||
const fork = child_process.fork;
|
|
||||||
const execFile = child_process.execFile;
|
|
||||||
const cmd = common.isWindows ? 'rundll32' : 'ls';
|
const cmd = common.isWindows ? 'rundll32' : 'ls';
|
||||||
const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
|
const invalidcmd = 'hopefully_you_dont_have_this_on_your_machine';
|
||||||
const invalidArgsMsg = /Incorrect value of args option/;
|
const invalidArgsMsg = /Incorrect value of args option/;
|
||||||
const invalidOptionsMsg = /"options" argument must be an object/;
|
const invalidOptionsMsg = /"options" argument must be an object/;
|
||||||
const invalidFileMsg =
|
const invalidFileMsg =
|
||||||
/^TypeError: "file" argument must be a non-empty string$/;
|
/^TypeError: "file" argument must be a non-empty string$/;
|
||||||
const empty = `${common.fixturesDir}/empty.js`;
|
|
||||||
|
const empty = fixtures.path('empty.js');
|
||||||
|
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
const child = spawn(invalidcmd, 'this is not an array');
|
const child = spawn(invalidcmd, 'this is not an array');
|
||||||
|
@ -22,9 +22,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const sub = path.join(common.fixturesDir, 'print-chars.js');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const sub = fixtures.path('print-chars.js');
|
||||||
|
|
||||||
const n = 500000;
|
const n = 500000;
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const child = require('child_process');
|
const child = require('child_process');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
const nodejs = `"${process.execPath}"`;
|
const nodejs = `"${process.execPath}"`;
|
||||||
|
|
||||||
if (process.argv.length > 2) {
|
if (process.argv.length > 2) {
|
||||||
@ -138,7 +139,7 @@ child.exec(`${nodejs} --use-strict -p process.execArgv`,
|
|||||||
|
|
||||||
// Regression test for https://github.com/nodejs/node/issues/3574.
|
// Regression test for https://github.com/nodejs/node/issues/3574.
|
||||||
{
|
{
|
||||||
const emptyFile = path.join(common.fixturesDir, 'empty.js');
|
const emptyFile = fixtures.path('empty.js');
|
||||||
|
|
||||||
child.exec(`${nodejs} -e 'require("child_process").fork("${emptyFile}")'`,
|
child.exec(`${nodejs} -e 'require("child_process").fork("${emptyFile}")'`,
|
||||||
common.mustCall((err, stdout, stderr) => {
|
common.mustCall((err, stdout, stderr) => {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { exec, spawnSync } = require('child_process');
|
const { exec, spawnSync } = require('child_process');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const node = process.execPath;
|
const node = process.execPath;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const notFoundRE = /^Error: Cannot find module/m;
|
|||||||
'syntax/good_syntax_shebang',
|
'syntax/good_syntax_shebang',
|
||||||
'syntax/illegal_if_not_wrapped.js'
|
'syntax/illegal_if_not_wrapped.js'
|
||||||
].forEach(function(file) {
|
].forEach(function(file) {
|
||||||
file = path.join(common.fixturesDir, file);
|
file = fixtures.path(file);
|
||||||
|
|
||||||
// loop each possible option, `-c` or `--check`
|
// loop each possible option, `-c` or `--check`
|
||||||
syntaxArgs.forEach(function(args) {
|
syntaxArgs.forEach(function(args) {
|
||||||
@ -46,7 +46,7 @@ const notFoundRE = /^Error: Cannot find module/m;
|
|||||||
'syntax/bad_syntax_shebang.js',
|
'syntax/bad_syntax_shebang.js',
|
||||||
'syntax/bad_syntax_shebang'
|
'syntax/bad_syntax_shebang'
|
||||||
].forEach(function(file) {
|
].forEach(function(file) {
|
||||||
file = path.join(common.fixturesDir, file);
|
file = fixtures.path(file);
|
||||||
|
|
||||||
// loop each possible option, `-c` or `--check`
|
// loop each possible option, `-c` or `--check`
|
||||||
syntaxArgs.forEach(function(args) {
|
syntaxArgs.forEach(function(args) {
|
||||||
@ -73,7 +73,7 @@ const notFoundRE = /^Error: Cannot find module/m;
|
|||||||
'syntax/file_not_found.js',
|
'syntax/file_not_found.js',
|
||||||
'syntax/file_not_found'
|
'syntax/file_not_found'
|
||||||
].forEach(function(file) {
|
].forEach(function(file) {
|
||||||
file = path.join(common.fixturesDir, file);
|
file = fixtures.path(file);
|
||||||
|
|
||||||
// loop each possible option, `-c` or `--check`
|
// loop each possible option, `-c` or `--check`
|
||||||
syntaxArgs.forEach(function(args) {
|
syntaxArgs.forEach(function(args) {
|
||||||
|
@ -32,19 +32,18 @@ if (!common.hasCrypto)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
|
const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR;
|
||||||
const fixtDir = common.fixturesDir;
|
|
||||||
|
|
||||||
crypto.DEFAULT_ENCODING = 'latin1';
|
crypto.DEFAULT_ENCODING = 'latin1';
|
||||||
|
|
||||||
// Test Certificates
|
// Test Certificates
|
||||||
const certPem = fs.readFileSync(`${fixtDir}/test_cert.pem`, 'ascii');
|
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
const certPfx = fs.readFileSync(`${fixtDir}/test_cert.pfx`);
|
const certPfx = fixtures.readSync('test_cert.pfx');
|
||||||
const keyPem = fs.readFileSync(`${fixtDir}/test_key.pem`, 'ascii');
|
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
const rsaPubPem = fs.readFileSync(`${fixtDir}/test_rsa_pubkey.pem`, 'ascii');
|
const rsaPubPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
|
||||||
const rsaKeyPem = fs.readFileSync(`${fixtDir}/test_rsa_privkey.pem`, 'ascii');
|
const rsaKeyPem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
|
||||||
|
|
||||||
// PFX tests
|
// PFX tests
|
||||||
assert.doesNotThrow(function() {
|
assert.doesNotThrow(function() {
|
||||||
@ -405,7 +404,7 @@ const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
|
|||||||
assert.strictEqual(h1, h2, 'multipled updates');
|
assert.strictEqual(h1, h2, 'multipled updates');
|
||||||
|
|
||||||
// Test hashing for binary files
|
// Test hashing for binary files
|
||||||
const fn = path.join(fixtDir, 'sample.png');
|
const fn = fixtures.path('sample.png');
|
||||||
const sha1Hash = crypto.createHash('sha1');
|
const sha1Hash = crypto.createHash('sha1');
|
||||||
const fileStream = fs.createReadStream(fn);
|
const fileStream = fs.createReadStream(fn);
|
||||||
fileStream.on('data', function(data) {
|
fileStream.on('data', function(data) {
|
||||||
@ -614,9 +613,8 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
|||||||
// Test RSA signing and verification
|
// Test RSA signing and verification
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
const privateKey = fs.readFileSync(`${fixtDir}/test_rsa_privkey_2.pem`);
|
const privateKey = fixtures.readSync('test_rsa_privkey_2.pem');
|
||||||
|
const publicKey = fixtures.readSync('test_rsa_pubkey_2.pem');
|
||||||
const publicKey = fs.readFileSync(`${fixtDir}/test_rsa_pubkey_2.pem`);
|
|
||||||
|
|
||||||
const input = 'I AM THE WALRUS';
|
const input = 'I AM THE WALRUS';
|
||||||
|
|
||||||
@ -644,9 +642,8 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true);
|
|||||||
// Test DSA signing and verification
|
// Test DSA signing and verification
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
const privateKey = fs.readFileSync(`${fixtDir}/test_dsa_privkey.pem`);
|
const privateKey = fixtures.readSync('test_dsa_privkey.pem');
|
||||||
|
const publicKey = fixtures.readSync('test_dsa_pubkey.pem');
|
||||||
const publicKey = fs.readFileSync(`${fixtDir}/test_dsa_pubkey.pem`);
|
|
||||||
|
|
||||||
const input = 'I AM THE WALRUS';
|
const input = 'I AM THE WALRUS';
|
||||||
|
|
||||||
|
@ -26,15 +26,14 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
crypto.DEFAULT_ENCODING = 'buffer';
|
crypto.DEFAULT_ENCODING = 'buffer';
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
// Test Certificates
|
// Test Certificates
|
||||||
const spkacValid = fs.readFileSync(`${common.fixturesDir}/spkac.valid`);
|
const spkacValid = fixtures.readSync('spkac.valid');
|
||||||
const spkacFail = fs.readFileSync(`${common.fixturesDir}/spkac.fail`);
|
const spkacFail = fixtures.readSync('spkac.fail');
|
||||||
const spkacPem = fs.readFileSync(`${common.fixturesDir}/spkac.pem`);
|
const spkacPem = fixtures.readSync('spkac.pem');
|
||||||
|
|
||||||
const certificate = new crypto.Certificate();
|
const certificate = new crypto.Certificate();
|
||||||
|
|
||||||
|
@ -6,13 +6,16 @@ if (!common.hasCrypto)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const spawnSync = require('child_process').spawnSync;
|
const spawnSync = require('child_process').spawnSync;
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const FIPS_ENABLED = 1;
|
const FIPS_ENABLED = 1;
|
||||||
const FIPS_DISABLED = 0;
|
const FIPS_DISABLED = 0;
|
||||||
const FIPS_ERROR_STRING = 'Error: Cannot set FIPS mode';
|
const FIPS_ERROR_STRING = 'Error: Cannot set FIPS mode';
|
||||||
const OPTION_ERROR_STRING = 'bad option';
|
const OPTION_ERROR_STRING = 'bad option';
|
||||||
const CNF_FIPS_ON = path.join(common.fixturesDir, 'openssl_fips_enabled.cnf');
|
|
||||||
const CNF_FIPS_OFF = path.join(common.fixturesDir, 'openssl_fips_disabled.cnf');
|
const CNF_FIPS_ON = fixtures.path('openssl_fips_enabled.cnf');
|
||||||
|
const CNF_FIPS_OFF = fixtures.path('openssl_fips_disabled.cnf');
|
||||||
|
|
||||||
let num_children_ok = 0;
|
let num_children_ok = 0;
|
||||||
|
|
||||||
function compiledWithFips() {
|
function compiledWithFips() {
|
||||||
|
@ -5,8 +5,8 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Test hashing
|
// Test hashing
|
||||||
const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
|
const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
|
||||||
@ -74,7 +74,7 @@ const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex');
|
|||||||
assert.strictEqual(h1, h2, 'multipled updates');
|
assert.strictEqual(h1, h2, 'multipled updates');
|
||||||
|
|
||||||
// Test hashing for binary files
|
// Test hashing for binary files
|
||||||
const fn = path.join(common.fixturesDir, 'sample.png');
|
const fn = fixtures.path('sample.png');
|
||||||
const sha1Hash = crypto.createHash('sha1');
|
const sha1Hash = crypto.createHash('sha1');
|
||||||
const fileStream = fs.createReadStream(fn);
|
const fileStream = fs.createReadStream(fn);
|
||||||
fileStream.on('data', function(data) {
|
fileStream.on('data', function(data) {
|
||||||
|
@ -4,23 +4,23 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
|
||||||
const constants = crypto.constants;
|
const constants = crypto.constants;
|
||||||
const fixtDir = common.fixturesDir;
|
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Test certificates
|
// Test certificates
|
||||||
const certPem = fs.readFileSync(`${fixtDir}/test_cert.pem`, 'ascii');
|
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
const keyPem = fs.readFileSync(`${fixtDir}/test_key.pem`, 'ascii');
|
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
const rsaPubPem = fs.readFileSync(`${fixtDir}/test_rsa_pubkey.pem`, 'ascii');
|
const rsaPubPem = fixtures.readSync('test_rsa_pubkey.pem', 'ascii');
|
||||||
const rsaKeyPem = fs.readFileSync(`${fixtDir}/test_rsa_privkey.pem`, 'ascii');
|
const rsaKeyPem = fixtures.readSync('test_rsa_privkey.pem', 'ascii');
|
||||||
const rsaKeyPemEncrypted = fs.readFileSync(
|
const rsaKeyPemEncrypted = fixtures.readSync('test_rsa_privkey_encrypted.pem',
|
||||||
`${fixtDir}/test_rsa_privkey_encrypted.pem`, 'ascii');
|
'ascii');
|
||||||
const dsaPubPem = fs.readFileSync(`${fixtDir}/test_dsa_pubkey.pem`, 'ascii');
|
const dsaPubPem = fixtures.readSync('test_dsa_pubkey.pem', 'ascii');
|
||||||
const dsaKeyPem = fs.readFileSync(`${fixtDir}/test_dsa_privkey.pem`, 'ascii');
|
const dsaKeyPem = fixtures.readSync('test_dsa_privkey.pem', 'ascii');
|
||||||
const dsaKeyPemEncrypted = fs.readFileSync(
|
const dsaKeyPemEncrypted = fixtures.readSync('test_dsa_privkey_encrypted.pem',
|
||||||
`${fixtDir}/test_dsa_privkey_encrypted.pem`, 'ascii');
|
'ascii');
|
||||||
|
|
||||||
const decryptError =
|
const decryptError =
|
||||||
/^Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt$/;
|
/^Error: error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt$/;
|
||||||
@ -174,9 +174,8 @@ assert.throws(() => {
|
|||||||
// Test RSA signing and verification
|
// Test RSA signing and verification
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
const privateKey = fs.readFileSync(`${fixtDir}/test_rsa_privkey_2.pem`);
|
const privateKey = fixtures.readSync('test_rsa_privkey_2.pem');
|
||||||
|
const publicKey = fixtures.readSync('test_rsa_pubkey_2.pem');
|
||||||
const publicKey = fs.readFileSync(`${fixtDir}/test_rsa_pubkey_2.pem`);
|
|
||||||
|
|
||||||
const input = 'I AM THE WALRUS';
|
const input = 'I AM THE WALRUS';
|
||||||
|
|
||||||
|
@ -8,10 +8,11 @@ const fs = require('fs');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Test certificates
|
// Test certificates
|
||||||
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
|
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
const keyPem = fs.readFileSync(`${common.fixturesDir}/test_key.pem`, 'ascii');
|
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
const modSize = 1024;
|
const modSize = 1024;
|
||||||
|
|
||||||
// Test signing and verifying
|
// Test signing and verifying
|
||||||
@ -185,10 +186,7 @@ const modSize = 1024;
|
|||||||
assert.strictEqual(verified, true, 'verify (PSS)');
|
assert.strictEqual(verified, true, 'verify (PSS)');
|
||||||
}
|
}
|
||||||
|
|
||||||
const vectorfile = path.join(common.fixturesDir, 'pss-vectors.json');
|
const examples = JSON.parse(fixtures.readSync('pss-vectors.json', 'utf8'));
|
||||||
const examples = JSON.parse(fs.readFileSync(vectorfile, {
|
|
||||||
encoding: 'utf8'
|
|
||||||
}));
|
|
||||||
|
|
||||||
for (const key in examples) {
|
for (const key in examples) {
|
||||||
const example = examples[key];
|
const example = examples[key];
|
||||||
@ -246,9 +244,8 @@ const modSize = 1024;
|
|||||||
if (!common.opensslCli)
|
if (!common.opensslCli)
|
||||||
common.skip('node compiled without OpenSSL CLI.');
|
common.skip('node compiled without OpenSSL CLI.');
|
||||||
|
|
||||||
const pubfile = path.join(common.fixturesDir, 'keys/rsa_public_2048.pem');
|
const pubfile = fixtures.path('keys', 'rsa_public_2048.pem');
|
||||||
const privfile = path.join(common.fixturesDir, 'keys/rsa_private_2048.pem');
|
const privkey = fixtures.readKey('rsa_private_2048.pem');
|
||||||
const privkey = fs.readFileSync(privfile);
|
|
||||||
|
|
||||||
const msg = 'Test123';
|
const msg = 'Test123';
|
||||||
const s5 = crypto.createSign('RSA-SHA256')
|
const s5 = crypto.createSign('RSA-SHA256')
|
||||||
|
@ -27,16 +27,15 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
crypto.DEFAULT_ENCODING = 'buffer';
|
crypto.DEFAULT_ENCODING = 'buffer';
|
||||||
|
|
||||||
const fs = require('fs');
|
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
|
|
||||||
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.Server(options, (socket) => {
|
const server = tls.Server(options, (socket) => {
|
||||||
|
@ -27,16 +27,16 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const fs = require('fs');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
crypto.DEFAULT_ENCODING = 'buffer';
|
crypto.DEFAULT_ENCODING = 'buffer';
|
||||||
|
|
||||||
// Test Certificates
|
// Test Certificates
|
||||||
const caPem = fs.readFileSync(`${common.fixturesDir}/test_ca.pem`, 'ascii');
|
const caPem = fixtures.readSync('test_ca.pem', 'ascii');
|
||||||
const certPem = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`, 'ascii');
|
const certPem = fixtures.readSync('test_cert.pem', 'ascii');
|
||||||
const certPfx = fs.readFileSync(`${common.fixturesDir}/test_cert.pfx`);
|
const certPfx = fixtures.readSync('test_cert.pfx');
|
||||||
const keyPem = fs.readFileSync(`${common.fixturesDir}/test_key.pem`, 'ascii');
|
const keyPem = fixtures.readSync('test_key.pem', 'ascii');
|
||||||
|
|
||||||
// 'this' safety
|
// 'this' safety
|
||||||
// https://github.com/joyent/node/issues/6690
|
// https://github.com/joyent/node/issues/6690
|
||||||
@ -176,8 +176,8 @@ assert.throws(function() {
|
|||||||
// $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \
|
// $ openssl pkcs8 -topk8 -inform PEM -outform PEM -in mykey.pem \
|
||||||
// -out private_key.pem -nocrypt;
|
// -out private_key.pem -nocrypt;
|
||||||
// Then open private_key.pem and change its header and footer.
|
// Then open private_key.pem and change its header and footer.
|
||||||
const sha1_privateKey = fs.readFileSync(
|
const sha1_privateKey = fixtures.readSync('test_bad_rsa_privkey.pem',
|
||||||
`${common.fixturesDir}/test_bad_rsa_privkey.pem`, 'ascii');
|
'ascii');
|
||||||
// this would inject errors onto OpenSSL's error stack
|
// this would inject errors onto OpenSSL's error stack
|
||||||
crypto.createSign('sha1').sign(sha1_privateKey);
|
crypto.createSign('sha1').sign(sha1_privateKey);
|
||||||
}, /asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag/);
|
}, /asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag/);
|
||||||
|
@ -7,9 +7,10 @@ if (common.isSunOS || common.isWindows || common.isAIX)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
|
const dirname = `${common.tmpDir}/cwd-does-not-exist-${process.pid}`;
|
||||||
const abspathFile = require('path').join(common.fixturesDir, 'a.js');
|
const abspathFile = fixtures.path('a.js');
|
||||||
common.refreshTmpDir();
|
common.refreshTmpDir();
|
||||||
fs.mkdirSync(dirname);
|
fs.mkdirSync(dirname);
|
||||||
process.chdir(dirname);
|
process.chdir(dirname);
|
||||||
|
@ -21,11 +21,11 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const path = require('path');
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
setTimeout(common.mustCall(function() {
|
setTimeout(common.mustCall(function() {
|
||||||
const a = require(path.join(common.fixturesDir, 'a'));
|
const a = require(fixtures.path('a'));
|
||||||
assert.strictEqual(true, 'A' in a);
|
assert.strictEqual(true, 'A' in a);
|
||||||
assert.strictEqual('A', a.A());
|
assert.strictEqual('A', a.A());
|
||||||
assert.strictEqual('D', a.D());
|
assert.strictEqual('D', a.D());
|
||||||
|
@ -22,10 +22,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const emptyFile = path.join(common.fixturesDir, 'empty.txt');
|
const emptyFile = fixtures.path('empty.txt');
|
||||||
|
|
||||||
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
fs.open(emptyFile, 'r', common.mustCall((error, fd) => {
|
||||||
|
|
||||||
|
@ -22,11 +22,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
const file = path.join(common.fixturesDir, 'a.js');
|
const file = fixtures.path('a.js');
|
||||||
|
|
||||||
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) {
|
fs.open(file, 'a', 0o777, common.mustCall(function(err, fd) {
|
||||||
assert.ifError(err);
|
assert.ifError(err);
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const fn = path.join(common.fixturesDir, 'elipses.txt');
|
const fn = fixtures.path('elipses.txt');
|
||||||
|
|
||||||
const s = fs.readFileSync(fn, 'utf8');
|
const s = fs.readFileSync(fn, 'utf8');
|
||||||
for (let i = 0; i < s.length; i++) {
|
for (let i = 0; i < s.length; i++) {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
const encoding = 'base64';
|
const encoding = 'base64';
|
||||||
|
|
||||||
const example = path.join(common.fixturesDir, 'x.txt');
|
const example = fixtures.path('x.txt');
|
||||||
const assertStream = new stream.Writable({
|
const assertStream = new stream.Writable({
|
||||||
write: function(chunk, enc, next) {
|
write: function(chunk, enc, next) {
|
||||||
const expected = Buffer.from('xyz');
|
const expected = Buffer.from('xyz');
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
let openCount = 0;
|
let openCount = 0;
|
||||||
const _fsopen = fs.open;
|
const _fsopen = fs.open;
|
||||||
@ -11,7 +11,7 @@ const _fsclose = fs.close;
|
|||||||
|
|
||||||
const loopCount = 50;
|
const loopCount = 50;
|
||||||
const totalCheck = 50;
|
const totalCheck = 50;
|
||||||
const emptyTxt = path.join(common.fixturesDir, 'empty.txt');
|
const emptyTxt = fixtures.path('empty.txt');
|
||||||
|
|
||||||
fs.open = function() {
|
fs.open = function() {
|
||||||
openCount++;
|
openCount++;
|
||||||
|
@ -24,10 +24,10 @@ const common = require('../common');
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const fn = path.join(common.fixturesDir, 'elipses.txt');
|
const fn = fixtures.path('elipses.txt');
|
||||||
const rangeFile = path.join(common.fixturesDir, 'x.txt');
|
const rangeFile = fixtures.path('x.txt');
|
||||||
|
|
||||||
{
|
{
|
||||||
let paused = false;
|
let paused = false;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const filepath = path.join(common.fixturesDir, 'x.txt');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const filepath = fixtures.path('x.txt');
|
||||||
const fd = fs.openSync(filepath, 'r');
|
const fd = fs.openSync(filepath, 'r');
|
||||||
const expected = 'xyz\n';
|
const expected = 'xyz\n';
|
||||||
|
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const fn = path.join(common.fixturesDir, 'empty.txt');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const fn = fixtures.path('empty.txt');
|
||||||
|
|
||||||
fs.readFile(fn, function(err, data) {
|
fs.readFile(fn, function(err, data) {
|
||||||
assert.ok(data);
|
assert.ok(data);
|
||||||
|
@ -28,10 +28,10 @@ if (common.isFreeBSD)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
function test(env, cb) {
|
function test(env, cb) {
|
||||||
const filename = path.join(common.fixturesDir, 'test-fs-readfile-error.js');
|
const filename = fixtures.path('test-fs-readfile-error.js');
|
||||||
const execPath = `"${process.execPath}" "${filename}"`;
|
const execPath = `"${process.execPath}" "${filename}"`;
|
||||||
const options = { env: Object.assign(process.env, env) };
|
const options = { env: Object.assign(process.env, env) };
|
||||||
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
|
exec(execPath, options, common.mustCall((err, stdout, stderr) => {
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const dirName = path.resolve(common.fixturesDir, 'test-readfile-unlink');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const dirName = fixtures.path('test-readfile-unlink');
|
||||||
const fileName = path.resolve(dirName, 'test.bin');
|
const fileName = path.resolve(dirName, 'test.bin');
|
||||||
const buf = Buffer.alloc(512 * 1024, 42);
|
const buf = Buffer.alloc(512 * 1024, 42);
|
||||||
|
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const m = require('module');
|
const m = require('module');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const a = require(`${common.fixturesDir}/module-require/relative/dot.js`);
|
const a = require(fixtures.path('module-require', 'relative', 'dot.js'));
|
||||||
const b = require(`${common.fixturesDir}/module-require/relative/dot-slash.js`);
|
const b = require(fixtures.path('module-require', 'relative', 'dot-slash.js'));
|
||||||
|
|
||||||
assert.strictEqual(a.value, 42);
|
assert.strictEqual(a.value, 42);
|
||||||
assert.strictEqual(a, b, 'require(".") should resolve like require("./")');
|
assert.strictEqual(a, b, 'require(".") should resolve like require("./")');
|
||||||
|
|
||||||
process.env.NODE_PATH = `${common.fixturesDir}/module-require/relative`;
|
process.env.NODE_PATH = fixtures.path('module-require', 'relative');
|
||||||
m._initPaths();
|
m._initPaths();
|
||||||
|
|
||||||
const c = require('.');
|
const c = require('.');
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const common = require('../common');
|
const fixtures = require('../common/fixtures');
|
||||||
const fixturesRequire = require(`${common.fixturesDir}/require-bin/bin/req.js`);
|
|
||||||
|
const fixturesRequire =
|
||||||
|
require(fixtures.path('require-bin', 'bin', 'req.js'));
|
||||||
|
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
fixturesRequire,
|
fixturesRequire,
|
||||||
|
@ -21,10 +21,16 @@
|
|||||||
|
|
||||||
/* eslint-disable max-len */
|
/* eslint-disable max-len */
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const filePath = '/json-with-directory-name-module/module-stub/one-trailing-slash/two/three.js';
|
const fixtures = require('../common/fixtures');
|
||||||
const content = require(`${common.fixturesDir}${filePath}`);
|
|
||||||
|
const content =
|
||||||
|
require(fixtures.path('json-with-directory-name-module',
|
||||||
|
'module-stub',
|
||||||
|
'one-trailing-slash',
|
||||||
|
'two',
|
||||||
|
'three.js'));
|
||||||
|
|
||||||
assert.notStrictEqual(content.rocko, 'artischocko');
|
assert.notStrictEqual(content.rocko, 'artischocko');
|
||||||
assert.strictEqual(content, 'hello from module-stub!');
|
assert.strictEqual(content, 'hello from module-stub!');
|
||||||
|
@ -20,19 +20,13 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const filePath = path.join(
|
const content = require(fixtures.path('json-with-directory-name-module',
|
||||||
common.fixturesDir,
|
'module-stub', 'one', 'two',
|
||||||
'json-with-directory-name-module',
|
'three.js'));
|
||||||
'module-stub',
|
|
||||||
'one',
|
|
||||||
'two',
|
|
||||||
'three.js'
|
|
||||||
);
|
|
||||||
const content = require(filePath);
|
|
||||||
|
|
||||||
assert.notStrictEqual(content.rocko, 'artischocko');
|
assert.notStrictEqual(content.rocko, 'artischocko');
|
||||||
assert.strictEqual(content, 'hello from module-stub!');
|
assert.strictEqual(content, 'hello from module-stub!');
|
||||||
|
@ -20,12 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const path = require('path');
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
require(path.join(common.fixturesDir, 'invalid.json'));
|
require(fixtures.path('invalid.json'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
assert.ok(
|
assert.ok(
|
||||||
/test[/\\]fixtures[/\\]invalid\.json: Unexpected string/.test(err.message),
|
/test[/\\]fixtures[/\\]invalid\.json: Unexpected string/.test(err.message),
|
||||||
|
@ -6,19 +6,22 @@ const path = require('path');
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const { exec, spawn } = require('child_process');
|
const { exec, spawn } = require('child_process');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
common.refreshTmpDir();
|
common.refreshTmpDir();
|
||||||
|
|
||||||
const linkTarget = path.join(common.fixturesDir,
|
const linkTarget = fixtures.path('module-require-symlink',
|
||||||
'/module-require-symlink/node_modules/dep2/');
|
'node_modules',
|
||||||
|
'dep2');
|
||||||
|
|
||||||
const linkDir = path.join(
|
const linkDir = fixtures.path('module-require-symlink',
|
||||||
common.fixturesDir,
|
'node_modules',
|
||||||
'/module-require-symlink/node_modules/dep1/node_modules/dep2'
|
'dep1',
|
||||||
);
|
'node_modules',
|
||||||
|
'dep2');
|
||||||
|
|
||||||
const linkScriptTarget = path.join(common.fixturesDir,
|
const linkScriptTarget = fixtures.path('module-require-symlink',
|
||||||
'/module-require-symlink/symlinked.js');
|
'symlinked.js');
|
||||||
|
|
||||||
const linkScript = path.join(common.tmpDir, 'module-require-symlink.js');
|
const linkScript = path.join(common.tmpDir, 'module-require-symlink.js');
|
||||||
|
|
||||||
@ -44,8 +47,7 @@ function test() {
|
|||||||
fs.symlinkSync(linkScriptTarget, linkScript);
|
fs.symlinkSync(linkScriptTarget, linkScript);
|
||||||
|
|
||||||
// load symlinked-module
|
// load symlinked-module
|
||||||
const fooModule =
|
const fooModule = require(fixtures.path('/module-require-symlink/foo.js'));
|
||||||
require(path.join(common.fixturesDir, '/module-require-symlink/foo.js'));
|
|
||||||
assert.strictEqual(fooModule.dep1.bar.version, 'CORRECT_VERSION');
|
assert.strictEqual(fooModule.dep1.bar.version, 'CORRECT_VERSION');
|
||||||
assert.strictEqual(fooModule.dep2.bar.version, 'CORRECT_VERSION');
|
assert.strictEqual(fooModule.dep2.bar.version, 'CORRECT_VERSION');
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@
|
|||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const child = spawn(process.argv[0], [`${common.fixturesDir}/should_exit.js`]);
|
const child = spawn(process.argv[0], [fixtures.path('should_exit.js')]);
|
||||||
child.stdout.once('data', function() {
|
child.stdout.once('data', function() {
|
||||||
child.kill('SIGINT');
|
child.kill('SIGINT');
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
if (common.isWindows) {
|
if (common.isWindows) {
|
||||||
if (process.argv[2] === 'child') {
|
if (process.argv[2] === 'child') {
|
||||||
@ -13,7 +13,7 @@ if (common.isWindows) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const python = process.env.PYTHON || 'python';
|
const python = process.env.PYTHON || 'python';
|
||||||
const script = path.join(common.fixturesDir, 'spawn_closed_stdio.py');
|
const script = fixtures.path('spawn_closed_stdio.py');
|
||||||
const proc = spawn(python, [script, process.execPath, __filename, 'child']);
|
const proc = spawn(python, [script, process.execPath, __filename, 'child']);
|
||||||
proc.on('exit', common.mustCall(function(exitCode) {
|
proc.on('exit', common.mustCall(function(exitCode) {
|
||||||
assert.strictEqual(exitCode, 0);
|
assert.strictEqual(exitCode, 0);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const child_process = require('child_process');
|
const child_process = require('child_process');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const testScript = path.join(common.fixturesDir, 'catch-stdout-error.js');
|
const testScript = fixtures.path('catch-stdout-error.js');
|
||||||
|
|
||||||
const cmd = `${JSON.stringify(process.execPath)} ` +
|
const cmd = `${JSON.stringify(process.execPath)} ` +
|
||||||
`${JSON.stringify(testScript)} | ` +
|
`${JSON.stringify(testScript)} | ` +
|
||||||
|
@ -4,10 +4,10 @@ const assert = require('assert');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const scriptString = path.join(common.fixturesDir, 'print-chars.js');
|
const scriptString = fixtures.path('print-chars.js');
|
||||||
const scriptBuffer = path.join(common.fixturesDir,
|
const scriptBuffer = fixtures.path('print-chars-from-buffer.js');
|
||||||
'print-chars-from-buffer.js');
|
|
||||||
const tmpFile = path.join(common.tmpDir, 'stdout.txt');
|
const tmpFile = path.join(common.tmpDir, 'stdout.txt');
|
||||||
|
|
||||||
common.refreshTmpDir();
|
common.refreshTmpDir();
|
||||||
|
@ -3,32 +3,26 @@ const common = require('../common');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
|
||||||
const rl = require('readline');
|
const rl = require('readline');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const BOM = '\uFEFF';
|
const BOM = '\uFEFF';
|
||||||
|
|
||||||
// Get the data using a non-stream way to compare with the streamed data.
|
// Get the data using a non-stream way to compare with the streamed data.
|
||||||
const modelData = fs.readFileSync(
|
const modelData = fixtures.readSync('file-to-read-without-bom.txt', 'utf8');
|
||||||
path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8'
|
|
||||||
);
|
|
||||||
const modelDataFirstCharacter = modelData[0];
|
const modelDataFirstCharacter = modelData[0];
|
||||||
|
|
||||||
// Detect the number of forthcoming 'line' events for mustCall() 'expected' arg.
|
// Detect the number of forthcoming 'line' events for mustCall() 'expected' arg.
|
||||||
const lineCount = modelData.match(/\n/g).length;
|
const lineCount = modelData.match(/\n/g).length;
|
||||||
|
|
||||||
// Ensure both without-bom and with-bom test files are textwise equal.
|
// Ensure both without-bom and with-bom test files are textwise equal.
|
||||||
assert.strictEqual(
|
assert.strictEqual(fixtures.readSync('file-to-read-with-bom.txt', 'utf8'),
|
||||||
fs.readFileSync(
|
`${BOM}${modelData}`
|
||||||
path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8'
|
|
||||||
),
|
|
||||||
`${BOM}${modelData}`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// An unjustified BOM stripping with a non-BOM character unshifted to a stream.
|
// An unjustified BOM stripping with a non-BOM character unshifted to a stream.
|
||||||
const inputWithoutBOM = fs.createReadStream(
|
const inputWithoutBOM =
|
||||||
path.join(common.fixturesDir, 'file-to-read-without-bom.txt'), 'utf8'
|
fs.createReadStream(fixtures.path('file-to-read-without-bom.txt'), 'utf8');
|
||||||
);
|
|
||||||
|
|
||||||
inputWithoutBOM.once('readable', common.mustCall(() => {
|
inputWithoutBOM.once('readable', common.mustCall(() => {
|
||||||
const maybeBOM = inputWithoutBOM.read(1);
|
const maybeBOM = inputWithoutBOM.read(1);
|
||||||
@ -48,9 +42,8 @@ inputWithoutBOM.once('readable', common.mustCall(() => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// A justified BOM stripping.
|
// A justified BOM stripping.
|
||||||
const inputWithBOM = fs.createReadStream(
|
const inputWithBOM =
|
||||||
path.join(common.fixturesDir, 'file-to-read-with-bom.txt'), 'utf8'
|
fs.createReadStream(fixtures.path('file-to-read-with-bom.txt'), 'utf8');
|
||||||
);
|
|
||||||
|
|
||||||
inputWithBOM.once('readable', common.mustCall(() => {
|
inputWithBOM.once('readable', common.mustCall(() => {
|
||||||
const maybeBOM = inputWithBOM.read(1);
|
const maybeBOM = inputWithBOM.read(1);
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const path = require('path');
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const fixture = path.join(common.fixturesDir, 'x.txt');
|
assert.strictEqual(fs.readFileSync(fixtures.path('x.txt')).toString(), 'xyz\n');
|
||||||
|
|
||||||
assert.strictEqual(fs.readFileSync(fixture).toString(), 'xyz\n');
|
|
||||||
|
@ -28,11 +28,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const server = tls.createServer({
|
const server = tls.createServer({
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/0-dns/0-dns-key.pem`),
|
key: fixtures.readSync(['0-dns', '0-dns-key.pem']),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/0-dns/0-dns-cert.pem`)
|
cert: fixtures.readSync(['0-dns', '0-dns-cert.pem'])
|
||||||
}, function(c) {
|
}, function(c) {
|
||||||
c.once('data', function() {
|
c.once('data', function() {
|
||||||
c.destroy();
|
c.destroy();
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Adding a CA certificate to contextWithCert should not also add it to
|
// Adding a CA certificate to contextWithCert should not also add it to
|
||||||
// contextWithoutCert. This is tested by trying to connect to a server that
|
// contextWithoutCert. This is tested by trying to connect to a server that
|
||||||
// depends on that CA using contextWithoutCert.
|
// depends on that CA using contextWithoutCert.
|
||||||
|
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
assert, connect, keys, tls
|
assert, connect, keys, tls
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
const contextWithoutCert = tls.createSecureContext({});
|
const contextWithoutCert = tls.createSecureContext({});
|
||||||
const contextWithCert = tls.createSecureContext({});
|
const contextWithCert = tls.createSecureContext({});
|
||||||
|
@ -7,17 +7,12 @@ if (!common.hasCrypto)
|
|||||||
if (!common.opensslCli)
|
if (!common.opensslCli)
|
||||||
common.skip('node compiled without OpenSSL CLI.');
|
common.skip('node compiled without OpenSSL CLI.');
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
|
@ -29,18 +29,13 @@ if (!common.opensslCli)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
let success = false;
|
let success = false;
|
||||||
|
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = tls.Server({
|
const server = tls.Server({
|
||||||
|
@ -10,16 +10,11 @@ if (!process.features.tls_alpn || !process.features.tls_npn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverIP = common.localhostIPv4;
|
const serverIP = common.localhostIPv4;
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Check ca option can contain concatenated certs by prepending an unrelated
|
// Check ca option can contain concatenated certs by prepending an unrelated
|
||||||
// non-CA cert and showing that agent6's CA root is still found.
|
// non-CA cert and showing that agent6's CA root is still found.
|
||||||
|
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
assert, connect, keys
|
assert, connect, keys
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
connect({
|
connect({
|
||||||
client: {
|
client: {
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Check cert chain is received by client, and is completed with the ca cert
|
// Check cert chain is received by client, and is completed with the ca cert
|
||||||
// known to the client.
|
// known to the client.
|
||||||
|
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
assert, connect, debug, keys
|
assert, connect, debug, keys
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
// agent6-cert.pem includes cert for agent6 and ca3
|
// agent6-cert.pem includes cert for agent6 and ca3
|
||||||
connect({
|
connect({
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Check cert chain is received by client, and is completed with the ca cert
|
// Check cert chain is received by client, and is completed with the ca cert
|
||||||
// known to the client.
|
// known to the client.
|
||||||
|
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
assert, connect, debug, keys
|
assert, connect, debug, keys
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
|
|
||||||
// agent6-cert.pem includes cert for agent6 and ca3, split it apart and
|
// agent6-cert.pem includes cert for agent6 and ca3, split it apart and
|
||||||
|
@ -26,11 +26,10 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
const cert = fixtures.readSync('test_cert.pem');
|
||||||
const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
const key = fixtures.readSync('test_key.pem');
|
||||||
|
|
||||||
const conn = tls.connect({ cert, key, port: 0 }, common.mustNotCall());
|
const conn = tls.connect({ cert, key, port: 0 }, common.mustNotCall());
|
||||||
conn.on('error', function() {
|
conn.on('error', function() {
|
||||||
|
@ -30,11 +30,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`),
|
key: fixtures.readKey('agent2-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`)
|
cert: fixtures.readKey('agent2-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const big = Buffer.alloc(2 * 1024 * 1024, 'Y');
|
const big = Buffer.alloc(2 * 1024 * 1024, 'Y');
|
||||||
|
@ -5,18 +5,19 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`);
|
const key = fixtures.readKey('agent2-key.pem');
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`);
|
const cert = fixtures.readKey('agent2-cert.pem');
|
||||||
|
|
||||||
let nsuccess = 0;
|
let nsuccess = 0;
|
||||||
let nerror = 0;
|
let nerror = 0;
|
||||||
|
|
||||||
function loadDHParam(n) {
|
function loadDHParam(n) {
|
||||||
let path = common.fixturesDir;
|
const params = [`dh${n}.pem`];
|
||||||
if (n !== 'error') path += '/keys';
|
if (n !== 'error')
|
||||||
return fs.readFileSync(`${path}/dh${n}.pem`);
|
params.unshift('keys');
|
||||||
|
return fixtures.readSync(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(size, err, next) {
|
function test(size, err, next) {
|
||||||
|
@ -26,12 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
|
key: fixtures.readSync('test_key.pem'),
|
||||||
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
|
cert: fixtures.readSync('test_cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, common.mustCall(function(socket) {
|
const server = tls.createServer(options, common.mustCall(function(socket) {
|
||||||
@ -70,7 +69,7 @@ function rejectUnauthorized() {
|
|||||||
|
|
||||||
function authorized() {
|
function authorized() {
|
||||||
const socket = tls.connect(server.address().port, {
|
const socket = tls.connect(server.address().port, {
|
||||||
ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))],
|
ca: [fixtures.readSync('test_cert.pem')],
|
||||||
servername: 'localhost'
|
servername: 'localhost'
|
||||||
}, common.mustCall(function() {
|
}, common.mustCall(function() {
|
||||||
assert(socket.authorized);
|
assert(socket.authorized);
|
||||||
|
@ -25,9 +25,8 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const testCases =
|
const testCases =
|
||||||
[{ ca: ['ca1-cert'],
|
[{ ca: ['ca1-cert'],
|
||||||
@ -61,13 +60,9 @@ const testCases =
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
let successfulTests = 0;
|
let successfulTests = 0;
|
||||||
|
@ -6,11 +6,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const server = tls.createServer({
|
const server = tls.createServer({
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
}, function(c) {
|
}, function(c) {
|
||||||
}).listen(0, common.mustCall(function() {
|
}).listen(0, common.mustCall(function() {
|
||||||
const c = tls.connect(this.address().port, common.mustNotCall());
|
const c = tls.connect(this.address().port, common.mustNotCall());
|
||||||
|
@ -26,11 +26,11 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const server = tls.createServer({
|
const server = tls.createServer({
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
}, function(c) {
|
}, function(c) {
|
||||||
// Send close-notify without shutting down TCP socket
|
// Send close-notify without shutting down TCP socket
|
||||||
if (c._handle.shutdownSSL() !== 1)
|
if (c._handle.shutdownSSL() !== 1)
|
||||||
|
@ -6,16 +6,11 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const testCases = [
|
const testCases = [
|
||||||
|
@ -26,12 +26,11 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
common.refreshTmpDir();
|
common.refreshTmpDir();
|
||||||
|
@ -26,14 +26,13 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
let serverConnected = 0;
|
let serverConnected = 0;
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.Server(options, common.mustCall(function(socket) {
|
const server = tls.Server(options, common.mustCall(function(socket) {
|
||||||
|
@ -4,15 +4,14 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const stream = require('stream');
|
const stream = require('stream');
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const cert_dir = common.fixturesDir;
|
const options = { key: fixtures.readSync('test_key.pem'),
|
||||||
const options = { key: fs.readFileSync(`${cert_dir}/test_key.pem`),
|
cert: fixtures.readSync('test_cert.pem'),
|
||||||
cert: fs.readFileSync(`${cert_dir}/test_cert.pem`),
|
ca: [ fixtures.readSync('test_ca.pem') ],
|
||||||
ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ],
|
|
||||||
ciphers: 'AES256-GCM-SHA384' };
|
ciphers: 'AES256-GCM-SHA384' };
|
||||||
const content = 'hello world';
|
const content = 'hello world';
|
||||||
const recv_bufs = [];
|
const recv_bufs = [];
|
||||||
|
@ -5,14 +5,14 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const bonkers = Buffer.alloc(1024, 42);
|
const bonkers = Buffer.alloc(1024, 42);
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = net.createServer(common.mustCall(function(c) {
|
const server = net.createServer(common.mustCall(function(c) {
|
||||||
|
@ -31,10 +31,10 @@ if (!common.opensslCli)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`);
|
const key = fixtures.readKey('agent2-key.pem');
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`);
|
const cert = fixtures.readKey('agent2-cert.pem');
|
||||||
let nsuccess = 0;
|
let nsuccess = 0;
|
||||||
let ntests = 0;
|
let ntests = 0;
|
||||||
const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
|
const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
|
||||||
@ -44,9 +44,10 @@ common.expectWarning('SecurityWarning',
|
|||||||
'DH parameter is less than 2048 bits');
|
'DH parameter is less than 2048 bits');
|
||||||
|
|
||||||
function loadDHParam(n) {
|
function loadDHParam(n) {
|
||||||
let path = common.fixturesDir;
|
const params = [`dh${n}.pem`];
|
||||||
if (n !== 'error') path += '/keys';
|
if (n !== 'error')
|
||||||
return fs.readFileSync(`${path}/dh${n}.pem`);
|
params.unshift('keys');
|
||||||
|
return fixtures.readSync(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test(keylen, expectedCipher, cb) {
|
function test(keylen, expectedCipher, cb) {
|
||||||
|
@ -7,10 +7,10 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const fork = require('child_process').fork;
|
const { fork } = require('child_process');
|
||||||
|
|
||||||
if (process.env.CHILD) {
|
if (process.env.CHILD) {
|
||||||
const copts = {
|
const copts = {
|
||||||
@ -24,8 +24,8 @@ if (process.env.CHILD) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`),
|
cert: fixtures.readKey('agent1-cert.pem'),
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, common.mustCall(function(s) {
|
const server = tls.createServer(options, common.mustCall(function(s) {
|
||||||
@ -35,7 +35,7 @@ const server = tls.createServer(options, common.mustCall(function(s) {
|
|||||||
const env = {
|
const env = {
|
||||||
CHILD: 'yes',
|
CHILD: 'yes',
|
||||||
PORT: this.address().port,
|
PORT: this.address().port,
|
||||||
NODE_EXTRA_CA_CERTS: `${common.fixturesDir}/keys/ca1-cert.pem`,
|
NODE_EXTRA_CA_CERTS: fixtures.path('keys', 'ca1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
fork(__filename, { env: env }).on('exit', common.mustCall(function(status) {
|
fork(__filename, { env: env }).on('exit', common.mustCall(function(status) {
|
||||||
|
@ -26,11 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/ec-key.pem`),
|
key: fixtures.readKey('/ec-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/ec-cert.pem`)
|
cert: fixtures.readKey('ec-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, function(conn) {
|
const server = tls.createServer(options, function(conn) {
|
||||||
|
@ -8,11 +8,11 @@ if (common.opensslCli === false)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/test_cert.pem`);
|
const cert = fixtures.readSync('test_cert.pem');
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/test_key.pem`);
|
const key = fixtures.readSync('test_key.pem');
|
||||||
const server = tls.createServer({ cert: cert, key: key }, common.mustNotCall());
|
const server = tls.createServer({ cert: cert, key: key }, common.mustNotCall());
|
||||||
const errors = [];
|
const errors = [];
|
||||||
let stderr = '';
|
let stderr = '';
|
||||||
|
@ -28,16 +28,11 @@ if (!process.features.tls_npn)
|
|||||||
common.skip('Skipping because node compiled without NPN feature of OpenSSL.');
|
common.skip('Skipping because node compiled without NPN feature of OpenSSL.');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
|
@ -32,26 +32,22 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const join = require('path').join;
|
|
||||||
|
|
||||||
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
|
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
|
||||||
|
|
||||||
const pfx = fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
|
const pfx = fixtures.readKey('agent1-pfx.pem');
|
||||||
|
|
||||||
function test(testOptions, cb) {
|
function test(testOptions, cb) {
|
||||||
|
|
||||||
const keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
|
const key = fixtures.readKey('agent1-key.pem');
|
||||||
const certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
|
const cert = fixtures.readKey('agent1-cert.pem');
|
||||||
const caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
|
const ca = fixtures.readKey('ca1-cert.pem');
|
||||||
const key = fs.readFileSync(keyFile);
|
|
||||||
const cert = fs.readFileSync(certFile);
|
|
||||||
const ca = fs.readFileSync(caFile);
|
|
||||||
const options = {
|
const options = {
|
||||||
key: key,
|
key,
|
||||||
cert: cert,
|
cert,
|
||||||
ca: [ca]
|
ca: [ca]
|
||||||
};
|
};
|
||||||
let requestCount = 0;
|
let requestCount = 0;
|
||||||
|
@ -6,15 +6,14 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
let out = '';
|
let out = '';
|
||||||
|
|
||||||
const server = tls.createServer({
|
const server = tls.createServer({
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
}, function(c) {
|
}, function(c) {
|
||||||
c.end('hello');
|
c.end('hello');
|
||||||
}).listen(0, function() {
|
}).listen(0, function() {
|
||||||
|
@ -26,14 +26,14 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const http = require('http');
|
const http = require('http');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
let gotRequest = false;
|
let gotRequest = false;
|
||||||
|
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`);
|
const key = fixtures.readKey('agent1-key.pem');
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`);
|
const cert = fixtures.readKey('agent1-cert.pem');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: key,
|
key: key,
|
||||||
|
@ -26,12 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const passKey = fs.readFileSync(path.join(common.fixturesDir, 'pass-key.pem'));
|
const passKey = fixtures.readSync('pass-key.pem');
|
||||||
const rawKey = fs.readFileSync(path.join(common.fixturesDir, 'raw-key.pem'));
|
const rawKey = fixtures.readSync('raw-key.pem');
|
||||||
const cert = fs.readFileSync(path.join(common.fixturesDir, 'pass-cert.pem'));
|
const cert = fixtures.readSync('pass-cert.pem');
|
||||||
|
|
||||||
assert(Buffer.isBuffer(passKey));
|
assert(Buffer.isBuffer(passKey));
|
||||||
assert(Buffer.isBuffer(cert));
|
assert(Buffer.isBuffer(cert));
|
||||||
|
@ -26,12 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')),
|
key: fixtures.readSync('test_key.pem'),
|
||||||
cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))
|
cert: fixtures.readSync('test_cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const bufSize = 1024 * 1024;
|
const bufSize = 1024 * 1024;
|
||||||
|
@ -26,14 +26,13 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const join = require('path').join;
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-key.pem')),
|
key: fixtures.readKey('agent5-key.pem'),
|
||||||
cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-cert.pem')),
|
cert: fixtures.readKey('agent5-cert.pem'),
|
||||||
ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem')) ]
|
ca: [ fixtures.readKey('ca2-cert.pem') ]
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, function(cleartext) {
|
const server = tls.createServer(options, function(cleartext) {
|
||||||
|
@ -26,13 +26,12 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const join = require('path').join;
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(join(common.fixturesDir, 'agent.key')),
|
key: fixtures.readSync('agent.key'),
|
||||||
cert: fs.readFileSync(join(common.fixturesDir, 'multi-alice.crt'))
|
cert: fixtures.readSync('multi-alice.crt')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, function(cleartext) {
|
const server = tls.createServer(options, function(cleartext) {
|
||||||
|
@ -20,14 +20,14 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Verify that detailed getPeerCertificate() return value has all certs.
|
// Verify that detailed getPeerCertificate() return value has all certs.
|
||||||
|
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
assert, connect, debug, keys
|
assert, connect, debug, keys
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
connect({
|
connect({
|
||||||
client: { rejectUnauthorized: false },
|
client: { rejectUnauthorized: false },
|
||||||
|
@ -7,11 +7,9 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
const path = require('path');
|
|
||||||
|
|
||||||
const pfx = fs.readFileSync(
|
const pfx = fixtures.readKey('agent1-pfx.pem');
|
||||||
path.join(common.fixturesDir, 'keys', 'agent1-pfx.pem'));
|
|
||||||
|
|
||||||
const server = tls.createServer({
|
const server = tls.createServer({
|
||||||
pfx: pfx,
|
pfx: pfx,
|
||||||
|
@ -6,11 +6,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.Server(options, common.mustCall(function(socket) {
|
const server = tls.Server(options, common.mustCall(function(socket) {
|
||||||
|
@ -6,14 +6,14 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const sent = 'hello world';
|
const sent = 'hello world';
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
isServer: true,
|
isServer: true,
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
let ssl = null;
|
let ssl = null;
|
||||||
|
@ -5,12 +5,12 @@ if (!common.hasCrypto)
|
|||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const sslcontext = tls.createSecureContext({
|
const sslcontext = tls.createSecureContext({
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/test_cert.pem`),
|
cert: fixtures.readSync('test_cert.pem'),
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/test_key.pem`)
|
key: fixtures.readSync('test_key.pem')
|
||||||
});
|
});
|
||||||
|
|
||||||
let catchedServername;
|
let catchedServername;
|
||||||
@ -21,7 +21,7 @@ const pair = tls.createSecurePair(sslcontext, true, false, false, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// captured traffic from browser's request to https://www.google.com
|
// captured traffic from browser's request to https://www.google.com
|
||||||
const sslHello = fs.readFileSync(`${common.fixturesDir}/google_ssl_hello.bin`);
|
const sslHello = fixtures.readSync('google_ssl_hello.bin');
|
||||||
|
|
||||||
pair.encrypted.write(sslHello);
|
pair.encrypted.write(sslHello);
|
||||||
|
|
||||||
|
@ -29,13 +29,12 @@ if (!common.opensslCli)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const join = require('path').join;
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const fs = require('fs');
|
|
||||||
const spawn = require('child_process').spawn;
|
const spawn = require('child_process').spawn;
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString();
|
const key = fixtures.readSync('agent.key').toString();
|
||||||
const cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString();
|
const cert = fixtures.readSync('agent.crt').toString();
|
||||||
|
|
||||||
function log(a) {
|
function log(a) {
|
||||||
console.error(`***server*** ${a}`);
|
console.error(`***server*** ${a}`);
|
||||||
|
@ -6,11 +6,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`),
|
key: fixtures.readKey('agent1-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`)
|
cert: fixtures.readKey('agent1-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
const server = tls.createServer(options, function(s) {
|
const server = tls.createServer(options, function(s) {
|
||||||
|
@ -40,9 +40,8 @@ const assert = require('assert');
|
|||||||
const { spawn } = require('child_process');
|
const { spawn } = require('child_process');
|
||||||
const { SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION } =
|
const { SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION } =
|
||||||
require('crypto').constants;
|
require('crypto').constants;
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const testCases =
|
const testCases =
|
||||||
[{ title: 'Do not request certs. Everyone is unauthorized.',
|
[{ title: 'Do not request certs. Everyone is unauthorized.',
|
||||||
@ -128,14 +127,12 @@ const testCases =
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function filenamePEM(n) {
|
function filenamePEM(n) {
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
return fixtures.path('keys', `${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,10 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
const assert = require('assert');
|
||||||
|
const tls = require('tls');
|
||||||
|
const { spawn } = require('child_process');
|
||||||
|
|
||||||
if (!common.opensslCli)
|
if (!common.opensslCli)
|
||||||
common.skip('node compiled without OpenSSL CLI.');
|
common.skip('node compiled without OpenSSL CLI.');
|
||||||
@ -28,15 +32,6 @@ if (!common.opensslCli)
|
|||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const assert = require('assert');
|
|
||||||
const tls = require('tls');
|
|
||||||
const fs = require('fs');
|
|
||||||
const { join } = require('path');
|
|
||||||
const { spawn } = require('child_process');
|
|
||||||
|
|
||||||
const keyFile = join(common.fixturesDir, 'agent.key');
|
|
||||||
const certFile = join(common.fixturesDir, 'agent.crt');
|
|
||||||
|
|
||||||
doTest({ tickets: false }, function() {
|
doTest({ tickets: false }, function() {
|
||||||
doTest({ tickets: true }, function() {
|
doTest({ tickets: true }, function() {
|
||||||
doTest({ tickets: false, invalidSession: true }, function() {
|
doTest({ tickets: false, invalidSession: true }, function() {
|
||||||
@ -46,11 +41,11 @@ doTest({ tickets: false }, function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function doTest(testOptions, callback) {
|
function doTest(testOptions, callback) {
|
||||||
const key = fs.readFileSync(keyFile);
|
const key = fixtures.readSync('agent.key');
|
||||||
const cert = fs.readFileSync(certFile);
|
const cert = fixtures.readSync('agent.crt');
|
||||||
const options = {
|
const options = {
|
||||||
key: key,
|
key,
|
||||||
cert: cert,
|
cert,
|
||||||
ca: [cert],
|
ca: [cert],
|
||||||
requestCert: true,
|
requestCert: true,
|
||||||
rejectUnauthorized: false
|
rejectUnauthorized: false
|
||||||
@ -108,8 +103,8 @@ function doTest(testOptions, callback) {
|
|||||||
'-tls1',
|
'-tls1',
|
||||||
'-connect', `localhost:${this.address().port}`,
|
'-connect', `localhost:${this.address().port}`,
|
||||||
'-servername', 'ohgod',
|
'-servername', 'ohgod',
|
||||||
'-key', join(common.fixturesDir, 'agent.key'),
|
'-key', fixtures.path('agent.key'),
|
||||||
'-cert', join(common.fixturesDir, 'agent.crt'),
|
'-cert', fixtures.path('agent.crt'),
|
||||||
'-reconnect'
|
'-reconnect'
|
||||||
].concat(testOptions.tickets ? [] : '-no_ticket');
|
].concat(testOptions.tickets ? [] : '-no_ticket');
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ if (!common.hasCrypto)
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const exec = require('child_process').exec;
|
const exec = require('child_process').exec;
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`),
|
key: fixtures.readKey('agent2-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`),
|
cert: fixtures.readKey('agent2-cert.pem'),
|
||||||
ciphers: 'AES256-SHA'
|
ciphers: 'AES256-SHA'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -26,11 +26,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
key: fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`),
|
key: fixtures.readKey('agent2-key.pem'),
|
||||||
cert: fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`)
|
cert: fixtures.readKey('agent2-cert.pem')
|
||||||
};
|
};
|
||||||
|
|
||||||
// Contains a UTF8 only character
|
// Contains a UTF8 only character
|
||||||
|
@ -28,16 +28,11 @@ if (!process.features.tls_sni)
|
|||||||
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
|
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
|
@ -28,16 +28,12 @@ if (!process.features.tls_sni)
|
|||||||
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
|
common.skip('node compiled without OpenSSL or with old OpenSSL version.');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fs = require('fs');
|
|
||||||
const path = require('path');
|
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
function filenamePEM(n) {
|
|
||||||
return path.join(common.fixturesDir, 'keys', `${n}.pem`);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadPEM(n) {
|
function loadPEM(n) {
|
||||||
return fs.readFileSync(filenamePEM(n));
|
return fixtures.readKey(`${n}.pem`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverOptions = {
|
const serverOptions = {
|
||||||
|
@ -5,11 +5,11 @@ if (!common.hasCrypto)
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/keys/agent2-key.pem`);
|
const key = fixtures.readKey('agent2-key.pem');
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/keys/agent2-cert.pem`);
|
const cert = fixtures.readKey('agent2-cert.pem');
|
||||||
|
|
||||||
let tlsSocket;
|
let tlsSocket;
|
||||||
// tls server
|
// tls server
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
// Test directly created TLS sockets and options.
|
// Test directly created TLS sockets and options.
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const join = require('path').join;
|
|
||||||
const {
|
const {
|
||||||
connect, keys, tls
|
connect, keys, tls
|
||||||
} = require(join(common.fixturesDir, 'tls-connect'));
|
} = require(fixtures.path('tls-connect'));
|
||||||
|
|
||||||
test(undefined, (err) => {
|
test(undefined, (err) => {
|
||||||
assert.strictEqual(err.message, 'unable to verify the first certificate');
|
assert.strictEqual(err.message, 'unable to verify the first certificate');
|
||||||
|
@ -5,12 +5,13 @@ const common = require('../common');
|
|||||||
if (!common.hasCrypto)
|
if (!common.hasCrypto)
|
||||||
common.skip('missing crypto');
|
common.skip('missing crypto');
|
||||||
|
|
||||||
const fs = require('fs');
|
|
||||||
const net = require('net');
|
const net = require('net');
|
||||||
const tls = require('tls');
|
const tls = require('tls');
|
||||||
|
const fixtures = require('../common/fixtures');
|
||||||
|
|
||||||
|
const key = fixtures.readKey('agent1-key.pem');
|
||||||
|
const cert = fixtures.readKey('agent1-cert.pem');
|
||||||
|
|
||||||
const key = fs.readFileSync(`${common.fixturesDir}/keys/agent1-key.pem`);
|
|
||||||
const cert = fs.readFileSync(`${common.fixturesDir}/keys/agent1-cert.pem`);
|
|
||||||
const secureContext = tls.createSecureContext({ key, cert });
|
const secureContext = tls.createSecureContext({ key, cert });
|
||||||
|
|
||||||
const server = net.createServer(common.mustCall((conn) => {
|
const server = net.createServer(common.mustCall((conn) => {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user