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