@@ -29,27 +29,27 @@ func TestUnitPostAuth(t *testing.T) {
29
29
bodyCreator := func () ([]byte , error ) {
30
30
return []byte {0x12 , 0x34 }, nil
31
31
}
32
- _ , err = postAuth (context .TODO (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
32
+ _ , err = postAuth (context .Background (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
33
33
if err != nil {
34
34
t .Fatalf ("err: %v" , err )
35
35
}
36
36
sr .FuncAuthPost = postAuthTestError
37
- _ , err = postAuth (context .TODO (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
37
+ _ , err = postAuth (context .Background (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
38
38
if err == nil {
39
39
t .Fatal ("should have failed to auth for unknown reason" )
40
40
}
41
41
sr .FuncAuthPost = postAuthTestAppBadGatewayError
42
- _ , err = postAuth (context .TODO (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
42
+ _ , err = postAuth (context .Background (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
43
43
if err == nil {
44
44
t .Fatal ("should have failed to auth for unknown reason" )
45
45
}
46
46
sr .FuncAuthPost = postAuthTestAppForbiddenError
47
- _ , err = postAuth (context .TODO (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
47
+ _ , err = postAuth (context .Background (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
48
48
if err == nil {
49
49
t .Fatal ("should have failed to auth for unknown reason" )
50
50
}
51
51
sr .FuncAuthPost = postAuthTestAppUnexpectedError
52
- _ , err = postAuth (context .TODO (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
52
+ _ , err = postAuth (context .Background (), sr , sr .Client , & url.Values {}, make (map [string ]string ), bodyCreator , 0 )
53
53
if err == nil {
54
54
t .Fatal ("should have failed to auth for unknown reason" )
55
55
}
@@ -131,7 +131,8 @@ func postAuthCheckOAuth(
131
131
_ * http.Client ,
132
132
_ * url.Values , _ map [string ]string ,
133
133
bodyCreator bodyCreatorType ,
134
- _ time.Duration ) (* authResponse , error ) {
134
+ _ time.Duration ,
135
+ ) (* authResponse , error ) {
135
136
var ar authRequest
136
137
jsonBody , _ := bodyCreator ()
137
138
if err := json .Unmarshal (jsonBody , & ar ); err != nil {
@@ -408,7 +409,7 @@ func TestUnitAuthenticateWithTokenAccessor(t *testing.T) {
408
409
sc .rest = sr
409
410
410
411
// FuncPostAuth is set to fail, but AuthTypeTokenAccessor should not even make a call to FuncPostAuth
411
- resp , err := authenticate (context .TODO (), sc , []byte {}, []byte {})
412
+ resp , err := authenticate (context .Background (), sc , []byte {}, []byte {})
412
413
if err != nil {
413
414
t .Fatalf ("should not have failed, err %v" , err )
414
415
}
@@ -449,7 +450,7 @@ func TestUnitAuthenticate(t *testing.T) {
449
450
}
450
451
sc .rest = sr
451
452
452
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
453
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
453
454
if err == nil {
454
455
t .Fatal ("should have failed." )
455
456
}
@@ -458,7 +459,7 @@ func TestUnitAuthenticate(t *testing.T) {
458
459
t .Fatalf ("Snowflake error is expected. err: %v" , driverErr )
459
460
}
460
461
sr .FuncPostAuth = postAuthFailWrongAccount
461
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
462
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
462
463
if err == nil {
463
464
t .Fatal ("should have failed." )
464
465
}
@@ -467,7 +468,7 @@ func TestUnitAuthenticate(t *testing.T) {
467
468
t .Fatalf ("Snowflake error is expected. err: %v" , driverErr )
468
469
}
469
470
sr .FuncPostAuth = postAuthFailUnknown
470
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
471
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
471
472
if err == nil {
472
473
t .Fatal ("should have failed." )
473
474
}
@@ -477,7 +478,7 @@ func TestUnitAuthenticate(t *testing.T) {
477
478
}
478
479
ta .SetTokens ("bad-token" , "bad-master-token" , 1 )
479
480
sr .FuncPostAuth = postAuthSuccessWithErrorCode
480
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
481
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
481
482
if err == nil {
482
483
t .Fatal ("should have failed." )
483
484
}
@@ -491,7 +492,7 @@ func TestUnitAuthenticate(t *testing.T) {
491
492
}
492
493
ta .SetTokens ("bad-token" , "bad-master-token" , 1 )
493
494
sr .FuncPostAuth = postAuthSuccessWithInvalidErrorCode
494
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
495
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
495
496
if err == nil {
496
497
t .Fatal ("should have failed." )
497
498
}
@@ -501,7 +502,7 @@ func TestUnitAuthenticate(t *testing.T) {
501
502
}
502
503
sr .FuncPostAuth = postAuthSuccess
503
504
var resp * authResponseMain
504
- resp , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
505
+ resp , err = authenticate (context .Background (), sc , []byte {}, []byte {})
505
506
if err != nil {
506
507
t .Fatalf ("failed to auth. err: %v" , err )
507
508
}
@@ -533,7 +534,7 @@ func TestUnitAuthenticateSaml(t *testing.T) {
533
534
Host : "blah.okta.com" ,
534
535
}
535
536
sc .rest = sr
536
- _ , err = authenticate (context .TODO (), sc , []byte ("HTML data in bytes from" ), []byte {})
537
+ _ , err = authenticate (context .Background (), sc , []byte ("HTML data in bytes from" ), []byte {})
537
538
if err != nil {
538
539
t .Fatalf ("failed to run. err: %v" , err )
539
540
}
@@ -550,7 +551,7 @@ func TestUnitAuthenticateOAuth(t *testing.T) {
550
551
sc .cfg .Token = "oauthToken"
551
552
sc .cfg .Authenticator = AuthTypeOAuth
552
553
sc .rest = sr
553
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
554
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
554
555
if err != nil {
555
556
t .Fatalf ("failed to run. err: %v" , err )
556
557
}
@@ -566,14 +567,14 @@ func TestUnitAuthenticatePasscode(t *testing.T) {
566
567
sc .cfg .Passcode = "987654321"
567
568
sc .rest = sr
568
569
569
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
570
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
570
571
if err != nil {
571
572
t .Fatalf ("failed to run. err: %v" , err )
572
573
}
573
574
sr .FuncPostAuth = postAuthCheckPasscodeInPassword
574
575
sc .rest = sr
575
576
sc .cfg .PasscodeInPassword = true
576
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
577
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
577
578
if err != nil {
578
579
t .Fatalf ("failed to run. err: %v" , err )
579
580
}
@@ -594,7 +595,7 @@ func TestUnitAuthenticateJWT(t *testing.T) {
594
595
sc .rest = sr
595
596
596
597
// A valid JWT token should pass
597
- if _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {}); err != nil {
598
+ if _ , err = authenticate (context .Background (), sc , []byte {}, []byte {}); err != nil {
598
599
t .Fatalf ("failed to run. err: %v" , err )
599
600
}
600
601
@@ -604,7 +605,7 @@ func TestUnitAuthenticateJWT(t *testing.T) {
604
605
t .Error (err )
605
606
}
606
607
sc .cfg .PrivateKey = invalidPrivateKey
607
- if _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {}); err == nil {
608
+ if _ , err = authenticate (context .Background (), sc , []byte {}, []byte {}); err == nil {
608
609
t .Fatalf ("invalid token passed" )
609
610
}
610
611
}
@@ -619,20 +620,20 @@ func TestUnitAuthenticateUsernamePasswordMfa(t *testing.T) {
619
620
sc .cfg .Authenticator = AuthTypeUsernamePasswordMFA
620
621
sc .cfg .ClientRequestMfaToken = ConfigBoolTrue
621
622
sc .rest = sr
622
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
623
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
623
624
if err != nil {
624
625
t .Fatalf ("failed to run. err: %v" , err )
625
626
}
626
627
627
628
sr .FuncPostAuth = postAuthCheckUsernamePasswordMfaToken
628
629
sc .cfg .MfaToken = "mockedMfaToken"
629
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
630
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
630
631
if err != nil {
631
632
t .Fatalf ("failed to run. err: %v" , err )
632
633
}
633
634
634
635
sr .FuncPostAuth = postAuthCheckUsernamePasswordMfaFailed
635
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
636
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
636
637
if err == nil {
637
638
t .Fatal ("should have failed" )
638
639
}
@@ -648,7 +649,7 @@ func TestUnitAuthenticateWithConfigMFA(t *testing.T) {
648
649
sc .cfg .Authenticator = AuthTypeUsernamePasswordMFA
649
650
sc .cfg .ClientRequestMfaToken = ConfigBoolTrue
650
651
sc .rest = sr
651
- sc .ctx = context .TODO ()
652
+ sc .ctx = context .Background ()
652
653
err = authenticateWithConfig (sc )
653
654
if err != nil {
654
655
t .Fatalf ("failed to run. err: %v" , err )
@@ -665,20 +666,20 @@ func TestUnitAuthenticateExternalBrowser(t *testing.T) {
665
666
sc .cfg .Authenticator = AuthTypeExternalBrowser
666
667
sc .cfg .ClientStoreTemporaryCredential = ConfigBoolTrue
667
668
sc .rest = sr
668
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
669
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
669
670
if err != nil {
670
671
t .Fatalf ("failed to run. err: %v" , err )
671
672
}
672
673
673
674
sr .FuncPostAuth = postAuthCheckExternalBrowserToken
674
675
sc .cfg .IDToken = "mockedIDToken"
675
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
676
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
676
677
if err != nil {
677
678
t .Fatalf ("failed to run. err: %v" , err )
678
679
}
679
680
680
681
sr .FuncPostAuth = postAuthCheckExternalBrowserFailed
681
- _ , err = authenticate (context .TODO (), sc , []byte {}, []byte {})
682
+ _ , err = authenticate (context .Background (), sc , []byte {}, []byte {})
682
683
if err == nil {
683
684
t .Fatal ("should have failed" )
684
685
}
0 commit comments