mirror of https://github.com/actions/toolkit
fix tests
parent
f003268b32
commit
2785fc91aa
|
@ -37,7 +37,7 @@ describe('basics', () => {
|
||||||
// "user-agent": "typed-test-client-tests"
|
// "user-agent": "typed-test-client-tests"
|
||||||
// },
|
// },
|
||||||
// "origin": "173.95.152.44",
|
// "origin": "173.95.152.44",
|
||||||
// "url": "https://postman-echo.com/get"
|
// "url": "http://postman-echo.com/get"
|
||||||
// }
|
// }
|
||||||
|
|
||||||
it('does basic http get request', async () => {
|
it('does basic http get request', async () => {
|
||||||
|
@ -65,12 +65,12 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('does basic https get request', async () => {
|
it('does basic https get request', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/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()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does basic http get request with default headers', async () => {
|
it('does basic http get request with default headers', async () => {
|
||||||
|
@ -125,12 +125,12 @@ describe('basics', () => {
|
||||||
it('pipes a get request', async () => {
|
it('pipes a get request', async () => {
|
||||||
return new Promise<void>(async resolve => {
|
return new Promise<void>(async resolve => {
|
||||||
const file = fs.createWriteStream(sampleFilePath)
|
const file = fs.createWriteStream(sampleFilePath)
|
||||||
;(await _http.get('https://postman-echo.com/get')).message
|
;(await _http.get('http://postman-echo.com/get')).message
|
||||||
.pipe(file)
|
.pipe(file)
|
||||||
.on('close', () => {
|
.on('close', () => {
|
||||||
const body: string = fs.readFileSync(sampleFilePath).toString()
|
const body: string = fs.readFileSync(sampleFilePath).toString()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
resolve()
|
resolve()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -139,25 +139,25 @@ describe('basics', () => {
|
||||||
it('does basic get request with redirects', async () => {
|
it('does basic get request with redirects', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/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()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('does basic get request with redirects (303)', async () => {
|
it('does basic get request with redirects (303)', async () => {
|
||||||
const res: httpm.HttpClientResponse = await _http.get(
|
const res: httpm.HttpClientResponse = await _http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)}&status_code=303`
|
)}&status_code=303`
|
||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(200)
|
expect(res.message.statusCode).toBe(200)
|
||||||
const body: string = await res.readBody()
|
const body: string = await res.readBody()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns 404 for not found get request on redirect', async () => {
|
it('returns 404 for not found get request on redirect', async () => {
|
||||||
|
@ -178,7 +178,7 @@ describe('basics', () => {
|
||||||
)
|
)
|
||||||
const res: httpm.HttpClientResponse = await http.get(
|
const res: httpm.HttpClientResponse = await http.get(
|
||||||
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
`https://postman-echo.com/redirect-to?url=${encodeURIComponent(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)}`
|
)}`
|
||||||
)
|
)
|
||||||
expect(res.message.statusCode).toBe(302)
|
expect(res.message.statusCode).toBe(302)
|
||||||
|
@ -289,11 +289,11 @@ describe('basics', () => {
|
||||||
|
|
||||||
it('gets a json object', async () => {
|
it('gets a json object', async () => {
|
||||||
const jsonObj = await _http.getJson<HttpBinData>(
|
const jsonObj = await _http.getJson<HttpBinData>(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/get'
|
||||||
)
|
)
|
||||||
expect(jsonObj.statusCode).toBe(200)
|
expect(jsonObj.statusCode).toBe(200)
|
||||||
expect(jsonObj.result).toBeDefined()
|
expect(jsonObj.result).toBeDefined()
|
||||||
expect(jsonObj.result?.url).toBe('https://postman-echo.com/get')
|
expect(jsonObj.result?.url).toBe('http://postman-echo.com/get')
|
||||||
expect(jsonObj.result?.headers[httpm.Headers.Accept]).toBe(
|
expect(jsonObj.result?.headers[httpm.Headers.Accept]).toBe(
|
||||||
httpm.MediaTypes.ApplicationJson
|
httpm.MediaTypes.ApplicationJson
|
||||||
)
|
)
|
||||||
|
|
|
@ -12,7 +12,7 @@ describe('headers', () => {
|
||||||
it('preserves existing headers on getJson', async () => {
|
it('preserves existing headers on getJson', async () => {
|
||||||
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
const additionalHeaders = {[httpm.Headers.Accept]: 'foo'}
|
||||||
let jsonObj = await _http.getJson<any>(
|
let jsonObj = await _http.getJson<any>(
|
||||||
'https://postman-echo.com/get',
|
'http://postman-echo.com/get',
|
||||||
additionalHeaders
|
additionalHeaders
|
||||||
)
|
)
|
||||||
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('foo')
|
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('foo')
|
||||||
|
@ -26,7 +26,7 @@ describe('headers', () => {
|
||||||
[httpm.Headers.Accept]: 'baz'
|
[httpm.Headers.Accept]: 'baz'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObj = await httpWithHeaders.getJson<any>('https://postman-echo.com/get')
|
jsonObj = await httpWithHeaders.getJson<any>('http://postman-echo.com/get')
|
||||||
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
expect(jsonObj.result.headers[httpm.Headers.Accept]).toBe('baz')
|
||||||
expect(jsonObj.headers[httpm.Headers.ContentType]).toContain(
|
expect(jsonObj.headers[httpm.Headers.ContentType]).toContain(
|
||||||
httpm.MediaTypes.ApplicationJson
|
httpm.MediaTypes.ApplicationJson
|
||||||
|
|
|
@ -226,12 +226,12 @@ describe('proxy', () => {
|
||||||
process.env['https_proxy'] = _proxyUrl
|
process.env['https_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(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/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()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
expect(_proxyConnects).toEqual(['postman-echo.com:443'])
|
expect(_proxyConnects).toEqual(['postman-echo.com:443'])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -240,12 +240,12 @@ describe('proxy', () => {
|
||||||
process.env['no_proxy'] = 'postman-echo.com'
|
process.env['no_proxy'] = 'postman-echo.com'
|
||||||
const httpClient = new httpm.HttpClient()
|
const httpClient = new httpm.HttpClient()
|
||||||
const res: httpm.HttpClientResponse = await httpClient.get(
|
const res: httpm.HttpClientResponse = await httpClient.get(
|
||||||
'https://postman-echo.com/get'
|
'http://postman-echo.com/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()
|
||||||
const obj = JSON.parse(body)
|
const obj = JSON.parse(body)
|
||||||
expect(obj.url).toBe('https://postman-echo.com/get')
|
expect(obj.url).toBe('http://postman-echo.com/get')
|
||||||
expect(_proxyConnects).toHaveLength(0)
|
expect(_proxyConnects).toHaveLength(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue