Skip to content

Commit

Permalink
fix: read strict-ssl from npm config (#310)
Browse files Browse the repository at this point in the history
Close #308
  • Loading branch information
mlev committed May 20, 2020
1 parent fda7feb commit 3ede8d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class MongoBinaryDownload {
process.env.HTTPS_PROXY ||
process.env.HTTP_PROXY;

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

const urlObject = url.parse(downloadUrl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ MONGOMS_MD5_CHECK environment variable`, () => {
expect(callArg1.agent.proxy.href).toBe('http://user:pass@proxy:8080/');
});

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

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

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

const du = new MongoBinaryDownload({});
du.httpDownload = jest.fn();
Expand Down

0 comments on commit 3ede8d1

Please sign in to comment.