-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add proxy support (thanks @ChrisSG)
* Adds proxy support * adds tests for downloadOptions and proxy * sets tabsize to 2 spaces * added https-proxy-agent dependency * fixes linter errors * adds types to new functions * refactors setting https agent * fixes bug for setting agent * fixes linter errors * revert: changes for MongoBinaryDownloadUrl This class only provide URL where can be obtained binaries for current platform. * refactor: MongoBinaryDownload now determine proxy settings from ENV vars This class handle downloading, so better place for proxy setup is here. * fix: small other fixes * chore: update dependencies
- Loading branch information
Showing
7 changed files
with
1,547 additions
and
1,384 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* @flow */ | ||
|
||
import MongoBinaryDownload from '../MongoBinaryDownload'; | ||
|
||
describe('MongoBinaryDownload', () => { | ||
it('should use direct download', async () => { | ||
process.env['yarn_https-proxy'] = ''; | ||
process.env.yarn_proxy = ''; | ||
process.env['npm_config_https-proxy'] = ''; | ||
process.env.npm_config_proxy = ''; | ||
process.env.https_proxy = ''; | ||
process.env.http_proxy = ''; | ||
|
||
const du = new MongoBinaryDownload({}); | ||
// $FlowFixMe | ||
du.httpDownload = jest.fn(); | ||
|
||
await du.download('https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz'); | ||
expect(du.httpDownload).toHaveBeenCalledTimes(1); | ||
const callArg1 = du.httpDownload.mock.calls[0][0]; | ||
expect(callArg1.agent).toBeUndefined(); | ||
}); | ||
|
||
it('should pick up proxy from env vars', async () => { | ||
process.env['yarn_https-proxy'] = 'http://user:pass@proxy:8080'; | ||
|
||
const du = new MongoBinaryDownload({}); | ||
// $FlowFixMe | ||
du.httpDownload = jest.fn(); | ||
|
||
await du.download('https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-3.6.3.tgz'); | ||
expect(du.httpDownload).toHaveBeenCalledTimes(1); | ||
const callArg1 = du.httpDownload.mock.calls[0][0]; | ||
expect(callArg1.agent).toBeDefined(); | ||
expect(callArg1.agent.options.href).toBe('http://user:pass@proxy:8080/'); | ||
}); | ||
}); |
Oops, something went wrong.