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

Function TestLogoutRemovesHostAndKeyringToken

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

Source from the content-addressed store, hash-verified

360}
361
362func 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
385func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) {
386 // 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