MCPcopy Create free account
hub / github.com/cli/cli / TestLogoutRemovesHostAndKeyringToken

Function TestLogoutRemovesHostAndKeyringToken

internal/config/auth_config_test.go:377–398  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

375}
376
377func 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
400func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) {
401 // Given we have two accounts logged into a host

Callers

nothing calls this directly

Calls 6

GetFunction · 0.92
newTestAuthConfigFunction · 0.85
requireNoKeyFunction · 0.70
keyringServiceNameFunction · 0.70
LoginMethod · 0.65
LogoutMethod · 0.65

Tested by

no test coverage detected