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