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

Function TestLogoutOfActiveUserSwitchesUserIfPossible

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

Source from the content-addressed store, hash-verified

382}
383
384func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) {
385 // Given we have two accounts logged into a host
386 authCfg := newTestAuthConfig(t)
387 _, err := authCfg.Login("github.com", "inactive-user", "test-token-1", "ssh", true)
388 require.NoError(t, err)
389
390 _, err = authCfg.Login("github.com", "active-user", "test-token-2", "https", true)
391 require.NoError(t, err)
392
393 // When we logout of the active user
394 err = authCfg.Logout("github.com", "active-user")
395
396 // Then we return success and the inactive user is now active
397 require.NoError(t, err)
398 activeUser, err := authCfg.ActiveUser("github.com")
399 require.NoError(t, err)
400 require.Equal(t, "inactive-user", activeUser)
401
402 token, err := authCfg.TokenFromKeyring("github.com")
403 require.NoError(t, err)
404 require.Equal(t, "test-token-1", token)
405
406 usersForHost := authCfg.UsersForHost("github.com")
407 require.NotContains(t, "active-user", usersForHost)
408}
409
410func TestLogoutOfInactiveUserDoesNotSwitchUser(t *testing.T) {
411 // Given we have two accounts logged into a host

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected