@@ -310,8 +310,12 @@ func createSecurityProvider(mockClient *mockExternalLoginClient, initialToken *a
310
310
)
311
311
}
312
312
313
+ var testMutex sync.Mutex
314
+
313
315
func TestLoginOnlyOnce (t * testing.T ) {
314
316
t .Run ("login called only once across multiple requests" , func (t * testing.T ) {
317
+ testMutex .Lock ()
318
+ defer testMutex .Unlock ()
315
319
resetGlobalState ()
316
320
cleanup := setupTestHomeDir (t )
317
321
defer cleanup ()
@@ -343,6 +347,8 @@ func TestLoginOnlyOnce(t *testing.T) {
343
347
// }
344
348
// func TestNoLoginWhenTokenIsGiven(t *testing.T) {
345
349
t .Run ("no login performed when valid token provided initially" , func (t * testing.T ) {
350
+ testMutex .Lock ()
351
+ defer testMutex .Unlock ()
346
352
resetGlobalState ()
347
353
cleanup := setupTestHomeDir (t )
348
354
defer cleanup ()
@@ -373,6 +379,8 @@ func TestLoginOnlyOnce(t *testing.T) {
373
379
// }
374
380
// func TestRealInterceptWithGlobalCache2(t *testing.T) {
375
381
t .Run ("handles login failure gracefully" , func (t * testing.T ) {
382
+ testMutex .Lock ()
383
+ defer testMutex .Unlock ()
376
384
resetGlobalState ()
377
385
cleanup := setupTestHomeDir (t )
378
386
defer cleanup ()
@@ -397,6 +405,8 @@ func TestLoginOnlyOnce(t *testing.T) {
397
405
// }
398
406
// func TestRealInterceptWithGlobalCache5(t *testing.T) {
399
407
t .Run ("token cached via callback and reused after provider recreation" , func (t * testing.T ) {
408
+ testMutex .Lock ()
409
+ defer testMutex .Unlock ()
400
410
resetGlobalState ()
401
411
cleanup := setupTestHomeDir (t )
402
412
defer cleanup ()
0 commit comments