mirror of
https://github.com/nodejs/node.git
synced 2025-05-09 15:46:27 +00:00

Currently, test-cli-node-print-help uses common.hasFipsCrypto to determine if the test should check for the existence of FIPS related options (--enable-fips, and --force-fips). The FIPS options are available when node has been compiled against an OpenSSL library with FIPS support in which case the test would verify that these options are available. But by using crypto.fips (which uses crypto.getFips()) this would only be checked when fips has been enabled, but these options are available regardless if FIPS is enabled or disabled. This commit updates the test to use fipsMode from config to determine if the FIPS options existence should be checked. PR-URL: https://github.com/nodejs/node/pull/25510 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// The following tests assert that the node.cc PrintHelp() function
|
|
// returns the proper set of cli options when invoked
|
|
|
|
const assert = require('assert');
|
|
const { exec } = require('child_process');
|
|
const { internalBinding } = require('internal/test/binding');
|
|
const { fipsMode } = internalBinding('config');
|
|
let stdOut;
|
|
|
|
|
|
function startPrintHelpTest() {
|
|
exec(`${process.execPath} --help`, common.mustCall((err, stdout, stderr) => {
|
|
assert.ifError(err);
|
|
stdOut = stdout;
|
|
validateNodePrintHelp();
|
|
}));
|
|
}
|
|
|
|
function validateNodePrintHelp() {
|
|
const config = process.config;
|
|
const HAVE_OPENSSL = common.hasCrypto;
|
|
const NODE_HAVE_I18N_SUPPORT = common.hasIntl;
|
|
const HAVE_INSPECTOR = config.variables.v8_enable_inspector === 1;
|
|
|
|
const cliHelpOptions = [
|
|
{ compileConstant: HAVE_OPENSSL,
|
|
flags: [ '--openssl-config=...', '--tls-cipher-list=...',
|
|
'--use-bundled-ca', '--use-openssl-ca' ] },
|
|
{ compileConstant: fipsMode,
|
|
flags: [ '--enable-fips', '--force-fips' ] },
|
|
{ compileConstant: NODE_HAVE_I18N_SUPPORT,
|
|
flags: [ '--icu-data-dir=...', 'NODE_ICU_DATA' ] },
|
|
{ compileConstant: HAVE_INSPECTOR,
|
|
flags: [ '--inspect-brk[=[host:]port]', '--inspect-port=[host:]port',
|
|
'--inspect[=[host:]port]' ] },
|
|
];
|
|
|
|
cliHelpOptions.forEach(testForSubstring);
|
|
}
|
|
|
|
function testForSubstring(options) {
|
|
if (options.compileConstant) {
|
|
options.flags.forEach((flag) => {
|
|
assert.strictEqual(stdOut.indexOf(flag) !== -1, true,
|
|
`Missing flag ${flag} in ${stdOut}`);
|
|
});
|
|
} else {
|
|
options.flags.forEach((flag) => {
|
|
assert.strictEqual(stdOut.indexOf(flag), -1,
|
|
`Unexpected flag ${flag} in ${stdOut}`);
|
|
});
|
|
}
|
|
}
|
|
|
|
startPrintHelpTest();
|