@@ -179,6 +179,52 @@ describe('basics', () => {
179
179
done ( )
180
180
} )
181
181
182
+ it ( 'does not pass auth with diff hostname redirects' , async done => {
183
+ let headers = {
184
+ accept : 'application/json' ,
185
+ authorization : 'shhh'
186
+ }
187
+ let res : httpm . HttpClientResponse = await _http . get (
188
+ 'https://httpbin.org/redirect-to?url=' +
189
+ encodeURIComponent ( 'https://www.httpbin.org/get' ) ,
190
+ headers
191
+ )
192
+
193
+ expect ( res . message . statusCode ) . toBe ( 200 )
194
+ let body : string = await res . readBody ( )
195
+ let obj : any = JSON . parse ( body )
196
+ // httpbin "fixes" the casing
197
+ expect ( obj . headers [ 'Accept' ] ) . toBe ( 'application/json' )
198
+ expect ( obj . headers [ 'Authorization' ] ) . toBeUndefined ( )
199
+ expect ( obj . headers [ 'authorization' ] ) . toBeUndefined ( )
200
+ expect ( obj . url ) . toBe ( 'https://www.httpbin.org/get' )
201
+
202
+ done ( )
203
+ } )
204
+
205
+ it ( 'does not pass Auth with diff hostname redirects' , async done => {
206
+ let headers = {
207
+ Accept : 'application/json' ,
208
+ Authorization : 'shhh'
209
+ }
210
+ let res : httpm . HttpClientResponse = await _http . get (
211
+ 'https://httpbin.org/redirect-to?url=' +
212
+ encodeURIComponent ( 'https://www.httpbin.org/get' ) ,
213
+ headers
214
+ )
215
+
216
+ expect ( res . message . statusCode ) . toBe ( 200 )
217
+ let body : string = await res . readBody ( )
218
+ let obj : any = JSON . parse ( body )
219
+ // httpbin "fixes" the casing
220
+ expect ( obj . headers [ 'Accept' ] ) . toBe ( 'application/json' )
221
+ expect ( obj . headers [ 'Authorization' ] ) . toBeUndefined ( )
222
+ expect ( obj . headers [ 'authorization' ] ) . toBeUndefined ( )
223
+ expect ( obj . url ) . toBe ( 'https://www.httpbin.org/get' )
224
+
225
+ done ( )
226
+ } )
227
+
182
228
it ( 'does basic head request' , async done => {
183
229
let res : httpm . HttpClientResponse = await _http . head (
184
230
'http://httpbin.org/get'
0 commit comments