MCPcopy Index your code
hub / github.com/cli/cli / TestLogoutOfInactiveUserDoesNotSwitchUser

Function TestLogoutOfInactiveUserDoesNotSwitchUser

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

Source from the content-addressed store, hash-verified

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