Use postman-echo to replace httpbin

This commit is contained in:
Francesco Renzi
2023-05-23 12:23:56 +01:00
parent 457303960f
commit 672c88ec4b
5 changed files with 126 additions and 121 deletions

View File

@@ -15,18 +15,18 @@ describe('auth', () => {
bh
])
const res: httpm.HttpClientResponse = await http.get(
'http://httpbin.org/get'
'http://postman-echo.com/get'
)
expect(res.message.statusCode).toBe(200)
const body: string = await res.readBody()
const obj = JSON.parse(body)
const auth: string = obj.headers.Authorization
const auth: string = obj.headers.authorization
const creds: string = Buffer.from(
auth.substring('Basic '.length),
'base64'
).toString()
expect(creds).toBe('johndoe:password')
expect(obj.url).toBe('http://httpbin.org/get')
expect(obj.url).toBe('http://postman-echo.com/get')
})
it('does basic http get request with pat token auth', async () => {
@@ -39,18 +39,18 @@ describe('auth', () => {
ph
])
const res: httpm.HttpClientResponse = await http.get(
'http://httpbin.org/get'
'http://postman-echo.com/get'
)
expect(res.message.statusCode).toBe(200)
const body: string = await res.readBody()
const obj = JSON.parse(body)
const auth: string = obj.headers.Authorization
const auth: string = obj.headers.authorization
const creds: string = Buffer.from(
auth.substring('Basic '.length),
'base64'
).toString()
expect(creds).toBe(`PAT:${token}`)
expect(obj.url).toBe('http://httpbin.org/get')
expect(obj.url).toBe('http://postman-echo.com/get')
})
it('does basic http get request with pat token auth', async () => {
@@ -61,13 +61,13 @@ describe('auth', () => {
ph
])
const res: httpm.HttpClientResponse = await http.get(
'http://httpbin.org/get'
'http://postman-echo.com/get'
)
expect(res.message.statusCode).toBe(200)
const body: string = await res.readBody()
const obj = JSON.parse(body)
const auth: string = obj.headers.Authorization
const auth: string = obj.headers.authorization
expect(auth).toBe(`Bearer ${token}`)
expect(obj.url).toBe('http://httpbin.org/get')
expect(obj.url).toBe('http://postman-echo.com/get')
})
})