Skip to content

Commit 3ede8d1

Browse files
authored
fix: read strict-ssl from npm config (#310)
Close #308
1 parent fda7feb commit 3ede8d1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/mongodb-memory-server-core/src/util/MongoBinaryDownload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export default class MongoBinaryDownload {
146146
process.env.HTTPS_PROXY ||
147147
process.env.HTTP_PROXY;
148148

149-
const strictSsl = process.env['npm_config_strict-ssl'] === 'false' ? false : true;
149+
const strictSsl = process.env.npm_config_strict_ssl === 'true';
150150

151151
const urlObject = url.parse(downloadUrl);
152152

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownload-test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ MONGOMS_MD5_CHECK environment variable`, () => {
5353
expect(callArg1.agent.proxy.href).toBe('http://user:pass@proxy:8080/');
5454
});
5555

56-
it('should not reject unauthorized when strict-ssl is false in env vars', async () => {
57-
process.env['npm_config_strict-ssl'] = 'false';
56+
it('should not reject unauthorized when npm strict-ssl config is false', async () => {
57+
// npm sets false config value as empty string in env vars
58+
process.env['npm_config_strict_ssl'] = '';
5859

5960
const du = new MongoBinaryDownload({});
6061
du.httpDownload = jest.fn();
@@ -66,8 +67,9 @@ MONGOMS_MD5_CHECK environment variable`, () => {
6667
expect(callArg1.rejectUnauthorized).toBe(false);
6768
});
6869

69-
it('should reject unauthorized when strict-ssl is not in env vars', async () => {
70-
delete process.env['npm_config_strict-ssl'];
70+
it('should reject unauthorized when npm strict-ssl config is true', async () => {
71+
// npm sets true config value as string 'true' in env vars
72+
process.env['npm_config_strict_ssl'] = 'true';
7173

7274
const du = new MongoBinaryDownload({});
7375
du.httpDownload = jest.fn();

0 commit comments

Comments
 (0)