mirror of
https://github.com/actions/http-client.git
synced 2025-04-21 17:52:29 +00:00
chore(deps): Bump dependencies
Signed-off-by: Matthieu MOREL <mmorel-35@users.noreply.github.com> Co-Authored-By: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-Authored-By: Matthieu MOREL <mmorel-35@users.noreply.github.com> Co-Authored-By: MOREL Matthieu <matthieu.morel@cnp.fr>
This commit is contained in:
parent
5ea1c52929
commit
2c9ed579a9
3
.github/workflows/test.yml
vendored
3
.github/workflows/test.yml
vendored
@ -27,8 +27,9 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
cache: npm
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- name: npm install
|
||||
|
@ -27,9 +27,8 @@ describe('auth', () => {
|
||||
|
||||
it('does basic http get request with pat token auth', async () => {
|
||||
let token: string = 'scbfb44vxzku5l4xgc3qfazn3lpk4awflfryc76esaiq7aypcbhs'
|
||||
let ph: am.PersonalAccessTokenCredentialHandler = new am.PersonalAccessTokenCredentialHandler(
|
||||
token
|
||||
)
|
||||
let ph: am.PersonalAccessTokenCredentialHandler =
|
||||
new am.PersonalAccessTokenCredentialHandler(token)
|
||||
|
||||
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [ph])
|
||||
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
|
||||
|
@ -39,7 +39,7 @@ describe('basics', () => {
|
||||
// "url": "https://httpbin.org/get"
|
||||
// }
|
||||
|
||||
it('does basic http get request', async done => {
|
||||
it('does basic http get request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'http://httpbin.org/get'
|
||||
)
|
||||
@ -48,10 +48,9 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
expect(obj.headers['User-Agent']).toBeTruthy()
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http get request with no user agent', async done => {
|
||||
it('does basic http get request with no user agent', async () => {
|
||||
let http: httpm.HttpClient = new httpm.HttpClient()
|
||||
let res: httpm.HttpClientResponse = await http.get('http://httpbin.org/get')
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
@ -59,10 +58,9 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
expect(obj.headers['User-Agent']).toBeFalsy()
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic https get request', async done => {
|
||||
it('does basic https get request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'https://httpbin.org/get'
|
||||
)
|
||||
@ -70,10 +68,9 @@ describe('basics', () => {
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('https://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http get request with default headers', async done => {
|
||||
it('does basic http get request with default headers', async () => {
|
||||
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [], {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -87,10 +84,9 @@ describe('basics', () => {
|
||||
expect(obj.headers.Accept).toBe('application/json')
|
||||
expect(obj.headers['Content-Type']).toBe('application/json')
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http get request with merged headers', async done => {
|
||||
it('does basic http get request with merged headers', async () => {
|
||||
let http: httpm.HttpClient = new httpm.HttpClient('http-client-tests', [], {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
@ -111,7 +107,6 @@ describe('basics', () => {
|
||||
'application/x-www-form-urlencoded'
|
||||
)
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it('pipes a get request', () => {
|
||||
@ -123,12 +118,12 @@ describe('basics', () => {
|
||||
let body: string = fs.readFileSync(sampleFilePath).toString()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('https://httpbin.org/get')
|
||||
resolve()
|
||||
resolve('')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it.skip('does basic get request with redirects', async done => {
|
||||
it.skip('does basic get request with redirects', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'https://httpbin.org/redirect-to?url=' +
|
||||
encodeURIComponent('https://httpbin.org/get')
|
||||
@ -137,10 +132,9 @@ describe('basics', () => {
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('https://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it.skip('does basic get request with redirects (303)', async done => {
|
||||
it.skip('does basic get request with redirects (303)', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'https://httpbin.org/redirect-to?url=' +
|
||||
encodeURIComponent('https://httpbin.org/get') +
|
||||
@ -150,10 +144,9 @@ describe('basics', () => {
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('https://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it('returns 404 for not found get request on redirect', async done => {
|
||||
it('returns 404 for not found get request on redirect', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'https://httpbin.org/redirect-to?url=' +
|
||||
encodeURIComponent('https://httpbin.org/status/404') +
|
||||
@ -161,10 +154,9 @@ describe('basics', () => {
|
||||
)
|
||||
expect(res.message.statusCode).toBe(404)
|
||||
let body: string = await res.readBody()
|
||||
done()
|
||||
})
|
||||
|
||||
it.skip('does not follow redirects if disabled', async done => {
|
||||
it.skip('does not follow redirects if disabled', async () => {
|
||||
let http: httpm.HttpClient = new httpm.HttpClient(
|
||||
'typed-test-client-tests',
|
||||
null,
|
||||
@ -176,10 +168,9 @@ describe('basics', () => {
|
||||
)
|
||||
expect(res.message.statusCode).toBe(302)
|
||||
let body: string = await res.readBody()
|
||||
done()
|
||||
})
|
||||
|
||||
it.skip('does not pass auth with diff hostname redirects', async done => {
|
||||
it.skip('does not pass auth with diff hostname redirects', async () => {
|
||||
let headers = {
|
||||
accept: 'application/json',
|
||||
authorization: 'shhh'
|
||||
@ -198,11 +189,9 @@ describe('basics', () => {
|
||||
expect(obj.headers['Authorization']).toBeUndefined()
|
||||
expect(obj.headers['authorization']).toBeUndefined()
|
||||
expect(obj.url).toBe('https://www.httpbin.org/get')
|
||||
|
||||
done()
|
||||
})
|
||||
|
||||
it.skip('does not pass Auth with diff hostname redirects', async done => {
|
||||
it.skip('does not pass Auth with diff hostname redirects', async () => {
|
||||
let headers = {
|
||||
Accept: 'application/json',
|
||||
Authorization: 'shhh'
|
||||
@ -221,29 +210,25 @@ describe('basics', () => {
|
||||
expect(obj.headers['Authorization']).toBeUndefined()
|
||||
expect(obj.headers['authorization']).toBeUndefined()
|
||||
expect(obj.url).toBe('https://www.httpbin.org/get')
|
||||
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic head request', async done => {
|
||||
it('does basic head request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.head(
|
||||
'http://httpbin.org/get'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http delete request', async done => {
|
||||
it('does basic http delete request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.del(
|
||||
'http://httpbin.org/delete'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http post request', async done => {
|
||||
it('does basic http post request', async () => {
|
||||
let b: string = 'Hello World!'
|
||||
let res: httpm.HttpClientResponse = await _http.post(
|
||||
'http://httpbin.org/post',
|
||||
@ -254,10 +239,9 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.data).toBe(b)
|
||||
expect(obj.url).toBe('http://httpbin.org/post')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http patch request', async done => {
|
||||
it('does basic http patch request', async () => {
|
||||
let b: string = 'Hello World!'
|
||||
let res: httpm.HttpClientResponse = await _http.patch(
|
||||
'http://httpbin.org/patch',
|
||||
@ -268,31 +252,27 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.data).toBe(b)
|
||||
expect(obj.url).toBe('http://httpbin.org/patch')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http options request', async done => {
|
||||
it('does basic http options request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.options(
|
||||
'http://httpbin.org'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
let body: string = await res.readBody()
|
||||
done()
|
||||
})
|
||||
|
||||
it('returns 404 for not found get request', async done => {
|
||||
it('returns 404 for not found get request', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'http://httpbin.org/status/404'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(404)
|
||||
let body: string = await res.readBody()
|
||||
done()
|
||||
})
|
||||
|
||||
it('gets a json object', async () => {
|
||||
let jsonObj: ifm.ITypedResponse<HttpBinData> = await _http.getJson<
|
||||
HttpBinData
|
||||
>('https://httpbin.org/get')
|
||||
let jsonObj: ifm.ITypedResponse<HttpBinData> =
|
||||
await _http.getJson<HttpBinData>('https://httpbin.org/get')
|
||||
expect(jsonObj.statusCode).toBe(200)
|
||||
expect(jsonObj.result).toBeDefined()
|
||||
expect(jsonObj.result.url).toBe('https://httpbin.org/get')
|
||||
@ -305,18 +285,16 @@ describe('basics', () => {
|
||||
})
|
||||
|
||||
it('getting a non existent json object returns null', async () => {
|
||||
let jsonObj: ifm.ITypedResponse<HttpBinData> = await _http.getJson<
|
||||
HttpBinData
|
||||
>('https://httpbin.org/status/404')
|
||||
let jsonObj: ifm.ITypedResponse<HttpBinData> =
|
||||
await _http.getJson<HttpBinData>('https://httpbin.org/status/404')
|
||||
expect(jsonObj.statusCode).toBe(404)
|
||||
expect(jsonObj.result).toBeNull()
|
||||
})
|
||||
|
||||
it('posts a json object', async () => {
|
||||
let res: any = {name: 'foo'}
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> = await _http.postJson<
|
||||
HttpBinData
|
||||
>('https://httpbin.org/post', res)
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> =
|
||||
await _http.postJson<HttpBinData>('https://httpbin.org/post', res)
|
||||
expect(restRes.statusCode).toBe(200)
|
||||
expect(restRes.result).toBeDefined()
|
||||
expect(restRes.result.url).toBe('https://httpbin.org/post')
|
||||
@ -334,9 +312,8 @@ describe('basics', () => {
|
||||
|
||||
it('puts a json object', async () => {
|
||||
let res: any = {name: 'foo'}
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> = await _http.putJson<
|
||||
HttpBinData
|
||||
>('https://httpbin.org/put', res)
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> =
|
||||
await _http.putJson<HttpBinData>('https://httpbin.org/put', res)
|
||||
expect(restRes.statusCode).toBe(200)
|
||||
expect(restRes.result).toBeDefined()
|
||||
expect(restRes.result.url).toBe('https://httpbin.org/put')
|
||||
@ -355,9 +332,8 @@ describe('basics', () => {
|
||||
|
||||
it('patch a json object', async () => {
|
||||
let res: any = {name: 'foo'}
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> = await _http.patchJson<
|
||||
HttpBinData
|
||||
>('https://httpbin.org/patch', res)
|
||||
let restRes: ifm.ITypedResponse<HttpBinData> =
|
||||
await _http.patchJson<HttpBinData>('https://httpbin.org/patch', res)
|
||||
expect(restRes.statusCode).toBe(200)
|
||||
expect(restRes.result).toBeDefined()
|
||||
expect(restRes.result.url).toBe('https://httpbin.org/patch')
|
||||
|
@ -11,7 +11,7 @@ describe('basics', () => {
|
||||
_http.dispose()
|
||||
})
|
||||
|
||||
it('does basic http get request with keepAlive true', async done => {
|
||||
it('does basic http get request with keepAlive true', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.get(
|
||||
'http://httpbin.org/get'
|
||||
)
|
||||
@ -19,28 +19,25 @@ describe('basics', () => {
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.url).toBe('http://httpbin.org/get')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic head request with keepAlive true', async done => {
|
||||
it('does basic head request with keepAlive true', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.head(
|
||||
'http://httpbin.org/get'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http delete request with keepAlive true', async done => {
|
||||
it('does basic http delete request with keepAlive true', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.del(
|
||||
'http://httpbin.org/delete'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
let body: string = await res.readBody()
|
||||
let obj: any = JSON.parse(body)
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http post request with keepAlive true', async done => {
|
||||
it('does basic http post request with keepAlive true', async () => {
|
||||
let b: string = 'Hello World!'
|
||||
let res: httpm.HttpClientResponse = await _http.post(
|
||||
'http://httpbin.org/post',
|
||||
@ -51,10 +48,9 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.data).toBe(b)
|
||||
expect(obj.url).toBe('http://httpbin.org/post')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http patch request with keepAlive true', async done => {
|
||||
it('does basic http patch request with keepAlive true', async () => {
|
||||
let b: string = 'Hello World!'
|
||||
let res: httpm.HttpClientResponse = await _http.patch(
|
||||
'http://httpbin.org/patch',
|
||||
@ -65,15 +61,13 @@ describe('basics', () => {
|
||||
let obj: any = JSON.parse(body)
|
||||
expect(obj.data).toBe(b)
|
||||
expect(obj.url).toBe('http://httpbin.org/patch')
|
||||
done()
|
||||
})
|
||||
|
||||
it('does basic http options request with keepAlive true', async done => {
|
||||
it('does basic http options request with keepAlive true', async () => {
|
||||
let res: httpm.HttpClientResponse = await _http.options(
|
||||
'http://httpbin.org'
|
||||
)
|
||||
expect(res.message.statusCode).toBe(200)
|
||||
let body: string = await res.readBody()
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
@ -3,6 +3,7 @@ import * as httpm from '../_out'
|
||||
import * as pm from '../_out/proxy'
|
||||
import * as proxy from 'proxy'
|
||||
import * as tunnelm from 'tunnel'
|
||||
import {URL} from 'url'
|
||||
|
||||
let _proxyConnects: string[]
|
||||
let _proxyServer: http.Server
|
||||
@ -12,7 +13,7 @@ describe('proxy', () => {
|
||||
beforeAll(async () => {
|
||||
// Start proxy server
|
||||
_proxyServer = proxy()
|
||||
await new Promise(resolve => {
|
||||
await new Promise<void>(resolve => {
|
||||
const port = Number(_proxyUrl.split(':')[2])
|
||||
_proxyServer.listen(port, () => resolve())
|
||||
})
|
||||
@ -32,7 +33,7 @@ describe('proxy', () => {
|
||||
_clearVars()
|
||||
|
||||
// Stop proxy server
|
||||
await new Promise(resolve => {
|
||||
await new Promise<void>(resolve => {
|
||||
_proxyServer.once('close', () => resolve())
|
||||
_proxyServer.close()
|
||||
})
|
||||
|
5
auth.ts
5
auth.ts
@ -1,4 +1,4 @@
|
||||
import ifm = require('./interfaces')
|
||||
import * as ifm from './interfaces'
|
||||
|
||||
export class BasicCredentialHandler implements ifm.IRequestHandler {
|
||||
username: string
|
||||
@ -57,7 +57,8 @@ export class BearerCredentialHandler implements ifm.IRequestHandler {
|
||||
}
|
||||
|
||||
export class PersonalAccessTokenCredentialHandler
|
||||
implements ifm.IRequestHandler {
|
||||
implements ifm.IRequestHandler
|
||||
{
|
||||
token: string
|
||||
|
||||
constructor(token: string) {
|
||||
|
9
index.ts
9
index.ts
@ -1,7 +1,8 @@
|
||||
import http = require('http')
|
||||
import https = require('https')
|
||||
import ifm = require('./interfaces')
|
||||
import pm = require('./proxy')
|
||||
import * as http from 'http'
|
||||
import * as https from 'https'
|
||||
import * as ifm from './interfaces'
|
||||
import * as pm from './proxy'
|
||||
import {URL} from 'url'
|
||||
|
||||
let tunnel: any
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import http = require('http')
|
||||
import * as http from 'http'
|
||||
import {URL} from 'url'
|
||||
|
||||
export interface IHeaders {
|
||||
[key: string]: any
|
||||
|
4221
package-lock.json
generated
4221
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
14
package.json
14
package.json
@ -25,13 +25,13 @@
|
||||
},
|
||||
"homepage": "https://github.com/actions/http-client#readme",
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/node": "^12.12.31",
|
||||
"jest": "^25.1.0",
|
||||
"prettier": "^2.0.4",
|
||||
"proxy": "^1.0.1",
|
||||
"ts-jest": "^25.2.1",
|
||||
"typescript": "^3.8.3"
|
||||
"@types/jest": "^27.0.1",
|
||||
"@types/node": "^16.7.2",
|
||||
"jest": "^27.1.0",
|
||||
"prettier": "^2.3.2",
|
||||
"proxy": "^1.0.2",
|
||||
"ts-jest": "^27.0.5",
|
||||
"typescript": "^4.4.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"tunnel": "0.0.6"
|
||||
|
Loading…
Reference in New Issue
Block a user