@@ -37,7 +37,7 @@ describe('basics', () => {
37
37
// "user-agent": "typed-test-client-tests"
38
38
// },
39
39
// "origin": "173.95.152.44",
40
- // "url": "https ://postman-echo.com/get"
40
+ // "url": "http ://postman-echo.com/get"
41
41
// }
42
42
43
43
it ( 'does basic http get request' , async ( ) => {
@@ -63,16 +63,17 @@ describe('basics', () => {
63
63
expect ( obj . headers [ 'user-agent' ] ) . toBeFalsy ( )
64
64
} )
65
65
66
+ /* TODO write a mock rather then relying on a third party
66
67
it('does basic https get request', async () => {
67
68
const res: httpm.HttpClientResponse = await _http.get(
68
- 'https ://postman-echo.com/get'
69
+ 'http ://postman-echo.com/get'
69
70
)
70
71
expect(res.message.statusCode).toBe(200)
71
72
const body: string = await res.readBody()
72
73
const obj = JSON.parse(body)
73
- expect ( obj . url ) . toBe ( 'https ://postman-echo.com/get' )
74
+ expect(obj.url).toBe('http ://postman-echo.com/get')
74
75
})
75
-
76
+ */
76
77
it ( 'does basic http get request with default headers' , async ( ) => {
77
78
const http : httpm . HttpClient = new httpm . HttpClient (
78
79
'http-client-tests' ,
@@ -125,45 +126,45 @@ describe('basics', () => {
125
126
it ( 'pipes a get request' , async ( ) => {
126
127
return new Promise < void > ( async resolve => {
127
128
const file = fs . createWriteStream ( sampleFilePath )
128
- ; ( await _http . get ( 'https ://postman-echo.com/get' ) ) . message
129
+ ; ( await _http . get ( 'http ://postman-echo.com/get' ) ) . message
129
130
. pipe ( file )
130
131
. on ( 'close' , ( ) => {
131
132
const body : string = fs . readFileSync ( sampleFilePath ) . toString ( )
132
133
const obj = JSON . parse ( body )
133
- expect ( obj . url ) . toBe ( 'https ://postman-echo.com/get' )
134
+ expect ( obj . url ) . toBe ( 'http ://postman-echo.com/get' )
134
135
resolve ( )
135
136
} )
136
137
} )
137
138
} )
138
139
139
140
it ( 'does basic get request with redirects' , async ( ) => {
140
141
const res : httpm . HttpClientResponse = await _http . get (
141
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
142
- 'https ://postman-echo.com/get'
142
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
143
+ 'http ://postman-echo.com/get'
143
144
) } `
144
145
)
145
146
expect ( res . message . statusCode ) . toBe ( 200 )
146
147
const body : string = await res . readBody ( )
147
148
const obj = JSON . parse ( body )
148
- expect ( obj . url ) . toBe ( 'https ://postman-echo.com/get' )
149
+ expect ( obj . url ) . toBe ( 'http ://postman-echo.com/get' )
149
150
} )
150
151
151
152
it ( 'does basic get request with redirects (303)' , async ( ) => {
152
153
const res : httpm . HttpClientResponse = await _http . get (
153
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
154
- 'https ://postman-echo.com/get'
154
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
155
+ 'http ://postman-echo.com/get'
155
156
) } &status_code=303`
156
157
)
157
158
expect ( res . message . statusCode ) . toBe ( 200 )
158
159
const body : string = await res . readBody ( )
159
160
const obj = JSON . parse ( body )
160
- expect ( obj . url ) . toBe ( 'https ://postman-echo.com/get' )
161
+ expect ( obj . url ) . toBe ( 'http ://postman-echo.com/get' )
161
162
} )
162
163
163
164
it ( 'returns 404 for not found get request on redirect' , async ( ) => {
164
165
const res : httpm . HttpClientResponse = await _http . get (
165
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
166
- 'https ://postman-echo.com/status/404'
166
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
167
+ 'http ://postman-echo.com/status/404'
167
168
) } &status_code=303`
168
169
)
169
170
expect ( res . message . statusCode ) . toBe ( 404 )
@@ -177,8 +178,8 @@ describe('basics', () => {
177
178
{ allowRedirects : false }
178
179
)
179
180
const res : httpm . HttpClientResponse = await http . get (
180
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
181
- 'https ://postman-echo.com/get'
181
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
182
+ 'http ://postman-echo.com/get'
182
183
) } `
183
184
)
184
185
expect ( res . message . statusCode ) . toBe ( 302 )
@@ -191,8 +192,8 @@ describe('basics', () => {
191
192
authorization : 'shhh'
192
193
}
193
194
const res : httpm . HttpClientResponse = await _http . get (
194
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
195
- 'https ://www.postman-echo.com/get'
195
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
196
+ 'http ://www.postman-echo.com/get'
196
197
) } `,
197
198
headers
198
199
)
@@ -204,7 +205,7 @@ describe('basics', () => {
204
205
expect ( obj . headers [ httpm . Headers . Accept ] ) . toBe ( 'application/json' )
205
206
expect ( obj . headers [ 'Authorization' ] ) . toBeUndefined ( )
206
207
expect ( obj . headers [ 'authorization' ] ) . toBeUndefined ( )
207
- expect ( obj . url ) . toBe ( 'https ://www.postman-echo.com/get' )
208
+ expect ( obj . url ) . toBe ( 'http ://www.postman-echo.com/get' )
208
209
} )
209
210
210
211
it ( 'does not pass Auth with diff hostname redirects' , async ( ) => {
@@ -213,8 +214,8 @@ describe('basics', () => {
213
214
Authorization : 'shhh'
214
215
}
215
216
const res : httpm . HttpClientResponse = await _http . get (
216
- `https ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
217
- 'https ://www.postman-echo.com/get'
217
+ `http ://postman-echo.com/redirect-to?url=${ encodeURIComponent (
218
+ 'http ://www.postman-echo.com/get'
218
219
) } `,
219
220
headers
220
221
)
@@ -226,7 +227,7 @@ describe('basics', () => {
226
227
expect ( obj . headers [ httpm . Headers . Accept ] ) . toBe ( 'application/json' )
227
228
expect ( obj . headers [ 'Authorization' ] ) . toBeUndefined ( )
228
229
expect ( obj . headers [ 'authorization' ] ) . toBeUndefined ( )
229
- expect ( obj . url ) . toBe ( 'https ://www.postman-echo.com/get' )
230
+ expect ( obj . url ) . toBe ( 'http ://www.postman-echo.com/get' )
230
231
} )
231
232
232
233
it ( 'does basic head request' , async ( ) => {
@@ -289,11 +290,11 @@ describe('basics', () => {
289
290
290
291
it ( 'gets a json object' , async ( ) => {
291
292
const jsonObj = await _http . getJson < HttpBinData > (
292
- 'https ://postman-echo.com/get'
293
+ 'http ://postman-echo.com/get'
293
294
)
294
295
expect ( jsonObj . statusCode ) . toBe ( 200 )
295
296
expect ( jsonObj . result ) . toBeDefined ( )
296
- expect ( jsonObj . result ?. url ) . toBe ( 'https ://postman-echo.com/get' )
297
+ expect ( jsonObj . result ?. url ) . toBe ( 'http ://postman-echo.com/get' )
297
298
expect ( jsonObj . result ?. headers [ httpm . Headers . Accept ] ) . toBe (
298
299
httpm . MediaTypes . ApplicationJson
299
300
)
@@ -304,7 +305,7 @@ describe('basics', () => {
304
305
305
306
it ( 'getting a non existent json object returns null' , async ( ) => {
306
307
const jsonObj = await _http . getJson < HttpBinData > (
307
- 'https ://postman-echo.com/status/404'
308
+ 'http ://postman-echo.com/status/404'
308
309
)
309
310
expect ( jsonObj . statusCode ) . toBe ( 404 )
310
311
expect ( jsonObj . result ) . toBeNull ( )
@@ -313,12 +314,12 @@ describe('basics', () => {
313
314
it ( 'posts a json object' , async ( ) => {
314
315
const res = { name : 'foo' }
315
316
const restRes = await _http . postJson < HttpBinData > (
316
- 'https ://postman-echo.com/post' ,
317
+ 'http ://postman-echo.com/post' ,
317
318
res
318
319
)
319
320
expect ( restRes . statusCode ) . toBe ( 200 )
320
321
expect ( restRes . result ) . toBeDefined ( )
321
- expect ( restRes . result ?. url ) . toBe ( 'https ://postman-echo.com/post' )
322
+ expect ( restRes . result ?. url ) . toBe ( 'http ://postman-echo.com/post' )
322
323
expect ( restRes . result ?. json . name ) . toBe ( 'foo' )
323
324
expect ( restRes . result ?. headers [ httpm . Headers . Accept ] ) . toBe (
324
325
httpm . MediaTypes . ApplicationJson
@@ -334,12 +335,12 @@ describe('basics', () => {
334
335
it ( 'puts a json object' , async ( ) => {
335
336
const res = { name : 'foo' }
336
337
const restRes = await _http . putJson < HttpBinData > (
337
- 'https ://postman-echo.com/put' ,
338
+ 'http ://postman-echo.com/put' ,
338
339
res
339
340
)
340
341
expect ( restRes . statusCode ) . toBe ( 200 )
341
342
expect ( restRes . result ) . toBeDefined ( )
342
- expect ( restRes . result ?. url ) . toBe ( 'https ://postman-echo.com/put' )
343
+ expect ( restRes . result ?. url ) . toBe ( 'http ://postman-echo.com/put' )
343
344
expect ( restRes . result ?. json . name ) . toBe ( 'foo' )
344
345
345
346
expect ( restRes . result ?. headers [ httpm . Headers . Accept ] ) . toBe (
@@ -356,12 +357,12 @@ describe('basics', () => {
356
357
it ( 'patch a json object' , async ( ) => {
357
358
const res = { name : 'foo' }
358
359
const restRes = await _http . patchJson < HttpBinData > (
359
- 'https ://postman-echo.com/patch' ,
360
+ 'http ://postman-echo.com/patch' ,
360
361
res
361
362
)
362
363
expect ( restRes . statusCode ) . toBe ( 200 )
363
364
expect ( restRes . result ) . toBeDefined ( )
364
- expect ( restRes . result ?. url ) . toBe ( 'https ://postman-echo.com/patch' )
365
+ expect ( restRes . result ?. url ) . toBe ( 'http ://postman-echo.com/patch' )
365
366
expect ( restRes . result ?. json . name ) . toBe ( 'foo' )
366
367
expect ( restRes . result ?. headers [ httpm . Headers . Accept ] ) . toBe (
367
368
httpm . MediaTypes . ApplicationJson
0 commit comments