mirror of https://github.com/actions/toolkit
Fix linting
parent
b708d5ba60
commit
e4ae385d1a
|
@ -223,43 +223,42 @@ describe('proxy', () => {
|
||||||
expect(_proxyConnects).toEqual(['httpbin.org:443'])
|
expect(_proxyConnects).toEqual(['httpbin.org:443'])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('HttpClient does basic https get request when bypass proxy', async () => {
|
it('HttpClient does basic https get request when bypass proxy', async () => {
|
||||||
process.env['https_proxy'] = _proxyUrl
|
process.env['https_proxy'] = _proxyUrl
|
||||||
process.env['no_proxy'] = 'httpbin.org'
|
process.env['no_proxy'] = 'httpbin.org'
|
||||||
const httpClient = new httpm.HttpClient()
|
|
||||||
const res: httpm.HttpClientResponse = await httpClient.get(
|
|
||||||
'https://httpbin.org/get'
|
|
||||||
)
|
|
||||||
expect(res.message.statusCode).toBe(200)
|
|
||||||
const body: string = await res.readBody()
|
|
||||||
const obj = JSON.parse(body)
|
|
||||||
expect(obj.url).toBe('https://httpbin.org/get')
|
|
||||||
expect(_proxyConnects).toHaveLength(0)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
|
||||||
// setup a server listening on localhost:8091
|
|
||||||
var server = http.createServer(function (request, response) {
|
|
||||||
response.writeHead(200);
|
|
||||||
request.pipe(response);
|
|
||||||
});
|
|
||||||
await server.listen(8091)
|
|
||||||
try {
|
|
||||||
process.env['http_proxy'] = _proxyUrl
|
|
||||||
const httpClient = new httpm.HttpClient()
|
const httpClient = new httpm.HttpClient()
|
||||||
const res: httpm.HttpClientResponse = await httpClient.get(
|
const res: httpm.HttpClientResponse = await httpClient.get(
|
||||||
'http://localhost:8091'
|
'https://httpbin.org/get'
|
||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(200)
|
expect(res.message.statusCode).toBe(200)
|
||||||
const body: string = await res.readBody()
|
const body: string = await res.readBody()
|
||||||
expect(body).toEqual('');
|
const obj = JSON.parse(body)
|
||||||
// proxy at _proxyUrl was ignored
|
expect(obj.url).toBe('https://httpbin.org/get')
|
||||||
expect(_proxyConnects).toEqual([])
|
expect(_proxyConnects).toHaveLength(0)
|
||||||
}
|
})
|
||||||
finally {
|
|
||||||
await server.close()
|
it('HttpClient bypasses proxy for loopback addresses (localhost, ::1, 127.*)', async () => {
|
||||||
}
|
// setup a server listening on localhost:8091
|
||||||
})
|
const server = http.createServer(function(request, response) {
|
||||||
|
response.writeHead(200)
|
||||||
|
request.pipe(response)
|
||||||
|
})
|
||||||
|
server.listen(8091)
|
||||||
|
try {
|
||||||
|
process.env['http_proxy'] = _proxyUrl
|
||||||
|
const httpClient = new httpm.HttpClient()
|
||||||
|
const res: httpm.HttpClientResponse = await httpClient.get(
|
||||||
|
'http://localhost:8091'
|
||||||
|
)
|
||||||
|
expect(res.message.statusCode).toBe(200)
|
||||||
|
const body: string = await res.readBody()
|
||||||
|
expect(body).toEqual('')
|
||||||
|
// proxy at _proxyUrl was ignored
|
||||||
|
expect(_proxyConnects).toEqual([])
|
||||||
|
} finally {
|
||||||
|
server.close()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('proxyAuth not set in tunnel agent when authentication is not provided', async () => {
|
it('proxyAuth not set in tunnel agent when authentication is not provided', async () => {
|
||||||
process.env['https_proxy'] = 'http://127.0.0.1:8080'
|
process.env['https_proxy'] = 'http://127.0.0.1:8080'
|
||||||
|
|
|
@ -74,5 +74,9 @@ export function checkBypass(reqUrl: URL): boolean {
|
||||||
|
|
||||||
function isLoopbackAddress(host: string): boolean {
|
function isLoopbackAddress(host: string): boolean {
|
||||||
const hostUpper = host.toUpperCase()
|
const hostUpper = host.toUpperCase()
|
||||||
return hostUpper === 'LOCALHOST' || hostUpper.startsWith('127.') || hostUpper.startsWith('::1')
|
return (
|
||||||
|
hostUpper === 'LOCALHOST' ||
|
||||||
|
hostUpper.startsWith('127.') ||
|
||||||
|
hostUpper.startsWith('::1')
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue