mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-04-29 21:18:06 +08:00
Add function to return proxy agent dispatcher for compatibility with latest octokit
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import * as http from 'http'
|
||||
import * as httpm from '../lib/'
|
||||
import * as pm from '../lib/proxy'
|
||||
import { ProxyAgent } from "undici";
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports
|
||||
const proxy = require('proxy')
|
||||
|
||||
@@ -13,7 +14,7 @@ const _proxyUrl = 'http://127.0.0.1:8080'
|
||||
describe('proxy', () => {
|
||||
beforeAll(async () => {
|
||||
// Start proxy server
|
||||
_proxyServer = proxy()
|
||||
_proxyServer = proxy.createProxy()
|
||||
await new Promise<void>(resolve => {
|
||||
const port = Number(_proxyUrl.split(':')[2])
|
||||
_proxyServer.listen(port, () => resolve())
|
||||
@@ -294,6 +295,15 @@ describe('proxy', () => {
|
||||
expect(agent.proxyOptions.port).toBe('8080')
|
||||
expect(agent.proxyOptions.proxyAuth).toBe('user:password')
|
||||
})
|
||||
|
||||
it('ProxyAgent is returned when proxy setting are provided', async () => {
|
||||
process.env['https_proxy'] = 'http://127.0.0.1:8080'
|
||||
const httpClient = new httpm.HttpClient()
|
||||
const agent = httpClient.getAgentDispatcher('https://some-url')
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(agent)
|
||||
expect(agent instanceof ProxyAgent).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
function _clearVars(): void {
|
||||
|
||||
Reference in New Issue
Block a user