1'use strict';
2const common = require('../common');
3
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const spawn = require('child_process').spawn;
9const defaultCoreList = require('crypto').constants.defaultCoreCipherList;
10
11function doCheck(arg, expression, check) {
12  let out = '';
13  arg = arg.concat([
14    '-pe',
15    expression,
16  ]);
17  spawn(process.execPath, arg, {})
18    .on('error', common.mustNotCall())
19    .stdout.on('data', function(chunk) {
20      out += chunk;
21    }).on('end', function() {
22      assert.strictEqual(out.trim(), check);
23    }).on('error', common.mustNotCall());
24}
25
26// Test the default unmodified version
27doCheck([], 'crypto.constants.defaultCipherList', defaultCoreList);
28doCheck([], 'tls.DEFAULT_CIPHERS', defaultCoreList);
29
30// Test the command line switch by itself
31doCheck(['--tls-cipher-list=ABC'], 'crypto.constants.defaultCipherList', 'ABC');
32doCheck(['--tls-cipher-list=ABC'], 'tls.DEFAULT_CIPHERS', 'ABC');
33