(t *testing.T)
| 398 | } |
| 399 | |
| 400 | func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) { |
| 401 | // Given we have two accounts logged into a host |
| 402 | authCfg := newTestAuthConfig(t) |
| 403 | _, err := authCfg.Login("github.com", "inactive-user", "test-token-1", "ssh", true) |
| 404 | require.NoError(t, err) |
| 405 | |
| 406 | _, err = authCfg.Login("github.com", "active-user", "test-token-2", "https", true) |
| 407 | require.NoError(t, err) |
| 408 | |
| 409 | // When we logout of the active user |
| 410 | err = authCfg.Logout("github.com", "active-user") |
| 411 | |
| 412 | // Then we return success and the inactive user is now active |
| 413 | require.NoError(t, err) |
| 414 | activeUser, err := authCfg.ActiveUser("github.com") |
| 415 | require.NoError(t, err) |
| 416 | require.Equal(t, "inactive-user", activeUser) |
| 417 | |
| 418 | token, err := authCfg.TokenFromKeyring("github.com") |
| 419 | require.NoError(t, err) |
| 420 | require.Equal(t, "test-token-1", token) |
| 421 | |
| 422 | usersForHost := authCfg.UsersForHost("github.com") |
| 423 | require.NotContains(t, "active-user", usersForHost) |
| 424 | } |
| 425 | |
| 426 | func TestLogoutOfInactiveUserDoesNotSwitchUser(t *testing.T) { |
| 427 | // Given we have two accounts logged into a host |
nothing calls this directly
no test coverage detected