@@ -681,7 +681,7 @@ func TestRequestAuthScheme(t *testing.T) {
681
681
assertEqual (t , http .StatusOK , resp .StatusCode ())
682
682
})
683
683
684
- t .Run ("empty auth scheme GH954" , func (t * testing.T ) {
684
+ t .Run ("empty auth scheme at client level GH954" , func (t * testing.T ) {
685
685
tokenValue := "004DDB79-6801-4587-B976-F093E6AC44FF"
686
686
687
687
// set client level
@@ -695,6 +695,38 @@ func TestRequestAuthScheme(t *testing.T) {
695
695
assertEqual (t , http .StatusOK , resp .StatusCode ())
696
696
assertEqual (t , tokenValue , resp .Request .Header .Get (hdrAuthorizationKey ))
697
697
})
698
+
699
+ t .Run ("empty auth scheme at request level GH954" , func (t * testing.T ) {
700
+ tokenValue := "004DDB79-6801-4587-B976-F093E6AC44FF"
701
+
702
+ // set client level
703
+ c := dcnl ().
704
+ SetTLSClientConfig (& tls.Config {InsecureSkipVerify : true }).
705
+ SetAuthToken (tokenValue )
706
+
707
+ resp , err := c .R ().
708
+ SetAuthScheme ("" ).
709
+ Get (ts .URL + "/profile" )
710
+
711
+ assertError (t , err )
712
+ assertEqual (t , http .StatusOK , resp .StatusCode ())
713
+ assertEqual (t , tokenValue , resp .Request .Header .Get (hdrAuthorizationKey ))
714
+ })
715
+
716
+ t .Run ("only client level auth token GH959" , func (t * testing.T ) {
717
+ tokenValue := "004DDB79-6801-4587-B976-F093E6AC44FF"
718
+
719
+ c := dcnl ().
720
+ SetTLSClientConfig (& tls.Config {InsecureSkipVerify : true }).
721
+ SetAuthToken (tokenValue )
722
+
723
+ resp , err := c .R ().
724
+ Get (ts .URL + "/profile" )
725
+
726
+ assertError (t , err )
727
+ assertEqual (t , http .StatusOK , resp .StatusCode ())
728
+ assertEqual (t , "Bearer " + tokenValue , resp .Request .Header .Get (hdrAuthorizationKey ))
729
+ })
698
730
}
699
731
700
732
func TestFormData (t * testing.T ) {
@@ -2364,6 +2396,11 @@ func TestRequestSettingsCoverage(t *testing.T) {
2364
2396
r5 .EnableRetryDefaultConditions ()
2365
2397
assertEqual (t , true , r5 .IsRetryDefaultConditions )
2366
2398
2399
+ r6 := c .R ()
2400
+ customAuthHeader := "X-Custom-Authorization"
2401
+ r6 .SetHeaderAuthorizationKey (customAuthHeader )
2402
+ assertEqual (t , customAuthHeader , r6 .HeaderAuthorizationKey )
2403
+
2367
2404
invalidJsonBytes := []byte (`{\" \": "value here"}` )
2368
2405
result := jsonIndent (invalidJsonBytes )
2369
2406
assertEqual (t , string (invalidJsonBytes ), string (result ))
@@ -2378,10 +2415,10 @@ func TestRequestSettingsCoverage(t *testing.T) {
2378
2415
}
2379
2416
}
2380
2417
}()
2381
- r6 := c .R ()
2418
+ rc := c .R ()
2382
2419
//lint:ignore SA1012 test case nil check
2383
- r62 := r6 .Clone (nil )
2384
- assertEqual (t , nil , r62 .ctx )
2420
+ rc2 := rc .Clone (nil )
2421
+ assertEqual (t , nil , rc2 .ctx )
2385
2422
}
2386
2423
2387
2424
func TestRequestDataRace (t * testing.T ) {
0 commit comments