(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func 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 | |
| 391 | func TestLogoutReloadsFreshConfigBeforeRemovingCredentials(t *testing.T) { |
| 392 | // A concurrent refresh can persist a rotated credential while logout is in flight. Because logout reloads the |
nothing calls this directly
no test coverage detected