MCPcopy Create free account
hub / github.com/cli/cli / TestLogoutAcquiresRefreshLock

Function TestLogoutAcquiresRefreshLock

internal/config/refreshable_test.go:372–389  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

370}
371
372func TestLogoutAcquiresRefreshLock(t *testing.T) {
373 // Logout must run under the same lock the refresh path uses so it wins any race with an in-flight refresh. Pin
374 // that it acquires and releases the shared refresh lock; without the fix Logout mutates the config without ever
375 // touching the lock and this fails.
376 authCfg := newTestAuthConfig(t)
377 _, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false)
378 require.NoError(t, err)
379
380 var locked, unlocked bool
381 authCfg.acquireRefreshLock = func(ctx context.Context, path string) (func(), error) {
382 locked = true
383 return func() { unlocked = true }, nil
384 }
385
386 require.NoError(t, authCfg.Logout("github.com", "test-user"))
387 require.True(t, locked, "logout must acquire the shared refresh lock")
388 require.True(t, unlocked, "logout must release the shared refresh lock")
389}
390
391func TestLogoutReloadsFreshConfigBeforeRemovingCredentials(t *testing.T) {
392 // A concurrent refresh can persist a rotated credential while logout is in flight. Because logout reloads the

Callers

nothing calls this directly

Calls 3

newTestAuthConfigFunction · 0.85
LoginMethod · 0.65
LogoutMethod · 0.65

Tested by

no test coverage detected