0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

test: fix test-tls-env-extra-ca-file-load

Fixes broken unit test for the NODE_EXTRA_CA_CERTS environment
variable. Unit test was exiting without evaluating any assertions
or running any tests.

Fixes: https://github.com/nodejs/node/issues/32072

PR-URL: https://github.com/nodejs/node/pull/32073
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Eric Bickle 2020-03-03 13:08:13 -08:00 committed by Anna Henningsen
parent b1a13b12f2
commit d53bcea2de
No known key found for this signature in database
GPG Key ID: A94130F0BFC8EBE9

View File

@ -16,14 +16,7 @@ const { fork } = require('child_process');
// This test ensures that extra certificates are loaded at startup.
if (process.argv[2] !== 'child') {
if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'yes') {
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), true);
} else if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'no') {
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false);
tls.createServer({});
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false);
}
} else {
// Parent
const NODE_EXTRA_CA_CERTS = fixtures.path('keys', 'ca1-cert.pem');
const extendsEnv = (obj) => ({ ...process.env, ...obj });
@ -37,4 +30,12 @@ if (process.argv[2] !== 'child') {
assert.strictEqual(status, 0);
}));
});
} else if (process.env.CHILD_USE_EXTRA_CA_CERTS === 'yes') {
// Child with extra certificates loaded at startup.
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), true);
} else {
// Child without extra certificates.
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false);
tls.createServer({});
assert.strictEqual(binding.isExtraRootCertsFileLoaded(), false);
}