(t *testing.T)
| 382 | } |
| 383 | |
| 384 | func 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 | |
| 410 | func TestLogoutOfInactiveUserDoesNotSwitchUser(t *testing.T) { |
| 411 | // Given we have two accounts logged into a host |
nothing calls this directly
no test coverage detected