MCPcopy
hub / github.com/cli/cli / TestLogoutRemovesHostAndKeyringToken

Function TestLogoutRemovesHostAndKeyringToken

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

Source from the content-addressed store, hash-verified

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