2015-08-17 15:51:51 -07:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
2017-07-01 02:29:09 +03:00
|
|
|
if (!common.hasCrypto)
|
2016-05-11 15:34:52 -04:00
|
|
|
common.skip('missing crypto');
|
2015-08-17 15:51:51 -07:00
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const spawn = require('child_process').spawn;
|
2016-05-02 10:27:12 -07:00
|
|
|
const defaultCoreList = require('crypto').constants.defaultCoreCipherList;
|
2015-08-17 15:51:51 -07:00
|
|
|
|
2020-04-10 13:04:10 +02:00
|
|
|
function doCheck(arg, expression, check) {
|
2017-01-08 13:19:00 +00:00
|
|
|
let out = '';
|
2016-01-30 21:46:45 -08:00
|
|
|
arg = arg.concat([
|
2015-08-17 15:51:51 -07:00
|
|
|
'-pe',
|
2020-04-10 13:04:10 +02:00
|
|
|
expression
|
2015-08-17 15:51:51 -07:00
|
|
|
]);
|
2016-09-18 01:43:49 -04:00
|
|
|
spawn(process.execPath, arg, {})
|
2017-02-03 14:54:19 -05:00
|
|
|
.on('error', common.mustNotCall())
|
2016-09-18 01:43:49 -04:00
|
|
|
.stdout.on('data', function(chunk) {
|
2015-08-17 15:51:51 -07:00
|
|
|
out += chunk;
|
|
|
|
}).on('end', function() {
|
2017-01-08 15:36:25 +00:00
|
|
|
assert.strictEqual(out.trim(), check);
|
2017-02-03 14:54:19 -05:00
|
|
|
}).on('error', common.mustNotCall());
|
2015-08-17 15:51:51 -07:00
|
|
|
}
|
|
|
|
|
2019-03-07 01:03:53 +01:00
|
|
|
// Test the default unmodified version
|
2020-04-10 13:04:10 +02:00
|
|
|
doCheck([], 'crypto.constants.defaultCipherList', defaultCoreList);
|
|
|
|
doCheck([], 'tls.DEFAULT_CIPHERS', defaultCoreList);
|
2015-08-17 15:51:51 -07:00
|
|
|
|
2019-03-07 01:03:53 +01:00
|
|
|
// Test the command line switch by itself
|
2020-04-10 13:04:10 +02:00
|
|
|
doCheck(['--tls-cipher-list=ABC'], 'crypto.constants.defaultCipherList', 'ABC');
|
|
|
|
doCheck(['--tls-cipher-list=ABC'], 'tls.DEFAULT_CIPHERS', 'ABC');
|