11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ciconst common = require('../common');
31cb0ef41Sopenharmony_ci
41cb0ef41Sopenharmony_ciif (!common.hasCrypto)
51cb0ef41Sopenharmony_ci  common.skip('missing crypto');
61cb0ef41Sopenharmony_ci
71cb0ef41Sopenharmony_ciconst assert = require('assert');
81cb0ef41Sopenharmony_ciconst spawn = require('child_process').spawn;
91cb0ef41Sopenharmony_ciconst defaultCoreList = require('crypto').constants.defaultCoreCipherList;
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cifunction doCheck(arg, expression, check) {
121cb0ef41Sopenharmony_ci  let out = '';
131cb0ef41Sopenharmony_ci  arg = arg.concat([
141cb0ef41Sopenharmony_ci    '-pe',
151cb0ef41Sopenharmony_ci    expression,
161cb0ef41Sopenharmony_ci  ]);
171cb0ef41Sopenharmony_ci  spawn(process.execPath, arg, {})
181cb0ef41Sopenharmony_ci    .on('error', common.mustNotCall())
191cb0ef41Sopenharmony_ci    .stdout.on('data', function(chunk) {
201cb0ef41Sopenharmony_ci      out += chunk;
211cb0ef41Sopenharmony_ci    }).on('end', function() {
221cb0ef41Sopenharmony_ci      assert.strictEqual(out.trim(), check);
231cb0ef41Sopenharmony_ci    }).on('error', common.mustNotCall());
241cb0ef41Sopenharmony_ci}
251cb0ef41Sopenharmony_ci
261cb0ef41Sopenharmony_ci// Test the default unmodified version
271cb0ef41Sopenharmony_cidoCheck([], 'crypto.constants.defaultCipherList', defaultCoreList);
281cb0ef41Sopenharmony_cidoCheck([], 'tls.DEFAULT_CIPHERS', defaultCoreList);
291cb0ef41Sopenharmony_ci
301cb0ef41Sopenharmony_ci// Test the command line switch by itself
311cb0ef41Sopenharmony_cidoCheck(['--tls-cipher-list=ABC'], 'crypto.constants.defaultCipherList', 'ABC');
321cb0ef41Sopenharmony_cidoCheck(['--tls-cipher-list=ABC'], 'tls.DEFAULT_CIPHERS', 'ABC');
33