11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci// This test checks the usage of --use-bundled-ca and --use-openssl-ca arguments
31cb0ef41Sopenharmony_ci// to verify that both are not used at the same time.
41cb0ef41Sopenharmony_ciconst common = require('../common');
51cb0ef41Sopenharmony_ciif (!common.hasCrypto)
61cb0ef41Sopenharmony_ci  common.skip('missing crypto');
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ciconst assert = require('assert');
91cb0ef41Sopenharmony_ciconst os = require('os');
101cb0ef41Sopenharmony_ciconst childProcess = require('child_process');
111cb0ef41Sopenharmony_ciconst result = childProcess.spawnSync(
121cb0ef41Sopenharmony_ci  process.execPath,
131cb0ef41Sopenharmony_ci  [ '--use-bundled-ca', '--use-openssl-ca', '-p', 'process.version' ],
141cb0ef41Sopenharmony_ci  { encoding: 'utf8' }
151cb0ef41Sopenharmony_ci);
161cb0ef41Sopenharmony_ci
171cb0ef41Sopenharmony_ciassert.strictEqual(result.stderr, `${process.execPath
181cb0ef41Sopenharmony_ci}: either --use-openssl-ca or --use-bundled-ca can be used, not both${os.EOL}`
191cb0ef41Sopenharmony_ci);
201cb0ef41Sopenharmony_ciassert.strictEqual(result.status, 9);
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ciconst useBundledCA = childProcess.spawnSync(process.execPath, [
231cb0ef41Sopenharmony_ci  '--use-bundled-ca',
241cb0ef41Sopenharmony_ci  '-p', 'process.version']);
251cb0ef41Sopenharmony_ciassert.strictEqual(useBundledCA.status, 0);
261cb0ef41Sopenharmony_ci
271cb0ef41Sopenharmony_ciconst useOpenSSLCA = childProcess.spawnSync(process.execPath, [
281cb0ef41Sopenharmony_ci  '--use-openssl-ca',
291cb0ef41Sopenharmony_ci  '-p', 'process.version']);
301cb0ef41Sopenharmony_ciassert.strictEqual(useOpenSSLCA.status, 0);
31