Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fixes #1057 - Proxy support
- Loading branch information
Showing
27 changed files
with
235 additions
and
26,537 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
let mockFetchArgs: {input: RequestInfo, init?: any}; | ||
jest.mock('node-fetch', () => { | ||
return async(input, init) => { | ||
mockFetchArgs = { input, init }; | ||
return { | ||
ok: true, | ||
json: async () => ({}), | ||
text: async () => '{}', | ||
}; | ||
}; | ||
}); | ||
|
||
import './fetchProxy'; | ||
|
||
describe('fetch proxy support', () => { | ||
it('should add the https-proxy-agent when the HTTPS_PROXY env var exists', async () => { | ||
process.env.HTTPS_PROXY = 'https://proxy'; | ||
await fetch('https://some.api.com'); | ||
expect(mockFetchArgs.init.agent).not.toBeNull(); | ||
}); | ||
|
||
it('should not add the https-proxy-agent when the HTTPS_PROXY env var exists but the NO_PROXY omits the url', () => { | ||
process.env.HTTPS_PROXY = 'https://proxy'; | ||
process.env.NO_PROXY = 'localhost'; | ||
fetch('https://localhost').catch(); | ||
expect(mockFetchArgs.init).toBeUndefined(); | ||
}); | ||
|
||
it('should not add the http-proxy-agent when the HTTPS_PROXY is omitted', () => { | ||
delete process.env.HTTPS_PROXY; | ||
delete process.env.NO_PROXY; | ||
fetch('https://localhost').catch(); | ||
expect(mockFetchArgs.init).toBeUndefined(); | ||
}); | ||
}); |
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,24 @@ | ||
// ------------------------------------------------------------------ | ||
// Proxy support | ||
const nodeFetch = require('node-fetch'); | ||
|
||
declare function fetch(input: RequestInfo, init?: RequestInit): Promise<Response>; | ||
|
||
(global as any).fetch = function (...args: any[]) { | ||
const [urlOrRequest, requestInit = {}] = args; | ||
// No Proxy | ||
const url: string = typeof urlOrRequest === 'string' ? urlOrRequest : urlOrRequest.url; | ||
if (!process.env.HTTPS_PROXY || (process.env.NO_PROXY && url.includes(process.env.NO_PROXY))) { | ||
return nodeFetch(...args); | ||
} | ||
// URL is first param attach the proxy | ||
// to the RequestInit | ||
const HttpsProxyAgent = require('https-proxy-agent'); | ||
const agent = new HttpsProxyAgent(process.env.HTTPS_PROXY); | ||
if (typeof urlOrRequest === 'string') { | ||
requestInit.agent = agent; | ||
} else { | ||
urlOrRequest.agent = agent; | ||
} | ||
return nodeFetch(urlOrRequest, requestInit); | ||
}; |
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
1 change: 1 addition & 0 deletions
1
packages/app/main/src/services/azureAuthWorkflowService.spec.ts
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
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
Oops, something went wrong.