(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestLogoutRemovesHostAndKeyringToken(t *testing.T) { |
| 362 | // Given we are logged into a host |
| 363 | authCfg := newTestAuthConfig(t) |
| 364 | host := "github.com" |
| 365 | user := "test-user" |
| 366 | token := "test-token" |
| 367 | |
| 368 | _, err := authCfg.Login(host, user, token, "ssh", true) |
| 369 | require.NoError(t, err) |
| 370 | |
| 371 | // When we logout |
| 372 | err = authCfg.Logout(host, user) |
| 373 | |
| 374 | // Then we return success, and the host and token are removed from the config and keyring |
| 375 | require.NoError(t, err) |
| 376 | |
| 377 | requireNoKey(t, authCfg.cfg, []string{hostsKey, host}) |
| 378 | _, err = keyring.Get(keyringServiceName(host), "") |
| 379 | require.ErrorContains(t, err, "secret not found in keyring") |
| 380 | _, err = keyring.Get(keyringServiceName(host), user) |
| 381 | require.ErrorContains(t, err, "secret not found in keyring") |
| 382 | } |
| 383 | |
| 384 | func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) { |
| 385 | // Given we have two accounts logged into a host |
nothing calls this directly
no test coverage detected