(t *testing.T)
| 375 | } |
| 376 | |
| 377 | func TestLogoutRemovesHostAndKeyringToken(t *testing.T) { |
| 378 | // Given we are logged into a host |
| 379 | authCfg := newTestAuthConfig(t) |
| 380 | host := "github.com" |
| 381 | user := "test-user" |
| 382 | token := "test-token" |
| 383 | |
| 384 | _, err := authCfg.Login(host, user, token, "ssh", true) |
| 385 | require.NoError(t, err) |
| 386 | |
| 387 | // When we logout |
| 388 | err = authCfg.Logout(host, user) |
| 389 | |
| 390 | // Then we return success, and the host and token are removed from the config and keyring |
| 391 | require.NoError(t, err) |
| 392 | |
| 393 | requireNoKey(t, authCfg.cfg, []string{hostsKey, host}) |
| 394 | _, err = keyring.Get(keyringServiceName(host), "") |
| 395 | require.ErrorContains(t, err, "secret not found in keyring") |
| 396 | _, err = keyring.Get(keyringServiceName(host), user) |
| 397 | require.ErrorContains(t, err, "secret not found in keyring") |
| 398 | } |
| 399 | |
| 400 | func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) { |
| 401 | // Given we have two accounts logged into a host |
nothing calls this directly
no test coverage detected