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

Function TestLogoutOfInactiveUserDoesNotSwitchUser

internal/config/auth_config_test.go:411–431  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

409}
410
411func TestLogoutOfInactiveUserDoesNotSwitchUser(t *testing.T) {
412 // Given we have two accounts logged into a host
413 authCfg := newTestAuthConfig(t)
414 _, err := authCfg.Login("github.com", "inactive-user-1", "test-token-1.1", "ssh", true)
415 require.NoError(t, err)
416
417 _, err = authCfg.Login("github.com", "inactive-user-2", "test-token-1.2", "ssh", true)
418 require.NoError(t, err)
419
420 _, err = authCfg.Login("github.com", "active-user", "test-token-2", "https", true)
421 require.NoError(t, err)
422
423 // When we logout of an inactive user
424 err = authCfg.Logout("github.com", "inactive-user-1")
425
426 // Then we return success and the active user is still active
427 require.NoError(t, err)
428 activeUser, err := authCfg.ActiveUser("github.com")
429 require.NoError(t, err)
430 require.Equal(t, "active-user", activeUser)
431}
432
433// Note that I'm not sure this test enforces particularly desirable behaviour
434// since it leads users to believe a token has been removed when really

Callers

nothing calls this directly

Calls 5

newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
LoginMethod · 0.65
LogoutMethod · 0.65
ActiveUserMethod · 0.65

Tested by

no test coverage detected