File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -395,6 +395,26 @@ func TestWithAuthToken(t *testing.T) {
395395 t .Parallel ()
396396 validate (t , NewTokenClient (t .Context (), token ).Client (), token )
397397 })
398+
399+ t .Run ("do not set Authorization when empty token" , func (t * testing.T ) {
400+ t .Parallel ()
401+ c := new (Client ).WithAuthToken ("" )
402+
403+ gotReq := false
404+ ifAuthorizationSet := false
405+ srv := httptest .NewServer (http .HandlerFunc (func (_ http.ResponseWriter , r * http.Request ) {
406+ gotReq = true
407+ _ , ifAuthorizationSet = r .Header ["Authorization" ]
408+ }))
409+ _ , err := c .client .Get (srv .URL )
410+ assertNilError (t , err )
411+ if ! gotReq {
412+ t .Error ("request not sent" )
413+ }
414+ if ifAuthorizationSet {
415+ t .Error ("The header 'Authorization' must not be set" )
416+ }
417+ })
398418}
399419
400420func TestWithEnterpriseURLs (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments