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