Skip to content

Commit

Permalink
Use postman-echo to replace httpbin
Browse files Browse the repository at this point in the history
  • Loading branch information
rentziass committed May 23, 2023
1 parent 4573039 commit 672c88e
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 121 deletions.
18 changes: 9 additions & 9 deletions packages/http-client/__tests__/auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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')
})
})
Loading

0 comments on commit 672c88e

Please sign in to comment.