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

Function TestLoginSucceedsWhenKeyringUnavailable

internal/config/refreshable_test.go:483–498  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

481}
482
483func TestLoginSucceedsWhenKeyringUnavailable(t *testing.T) {
484 // The refreshable-record purge is best effort against capability loss: an unavailable keyring must not fail an
485 // otherwise valid insecure login. refreshableFromKeyring collapses an unavailable keyring to "not found", so the
486 // purge's post-condition check resolves no surviving record and login stays silent. Without that, surfacing the
487 // keyring delete error would break login wherever the keyring is absent.
488 authCfg := newTestAuthConfig(t)
489 keyring.MockInitWithError(errors.New("keyring is unavailable"))
490
491 insecureStorageUsed, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false)
492 require.NoError(t, err)
493 require.True(t, insecureStorageUsed)
494
495 token, err := authCfg.cfg.Get([]string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey})
496 require.NoError(t, err)
497 require.Equal(t, "gho_token", token)
498}
499
500func TestSwitchUserActivatesRefreshableCredential(t *testing.T) {
501 authCfg := newTestAuthConfig(t)

Callers

nothing calls this directly

Calls 5

MockInitWithErrorFunction · 0.92
newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
LoginMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected