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

Function TestLogoutRemovesHostAndKeyringToken

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

Source from the content-addressed store, hash-verified

373}
374
375func 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
398func TestLogoutOfActiveUserSwitchesUserIfPossible(t *testing.T) {
399 // 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