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

Function TestLoginSucceedsWhenKeyringUnavailable

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

Source from the content-addressed store, hash-verified

642}
643
644func TestLoginSucceedsWhenKeyringUnavailable(t *testing.T) {
645 // The refreshable-record purge is best effort against capability loss: an unavailable keyring must not fail an
646 // otherwise valid insecure login. refreshableFromKeyring collapses an unavailable keyring to "not found", so the
647 // purge's post-condition check resolves no surviving record and login stays silent. Without that, surfacing the
648 // keyring delete error would break login wherever the keyring is absent.
649 authCfg := newTestAuthConfig(t)
650 keyring.MockInitWithError(errors.New("keyring is unavailable"))
651
652 insecureStorageUsed, err := authCfg.Login("github.com", "test-user", "gho_token", "https", false)
653 require.NoError(t, err)
654 require.True(t, insecureStorageUsed)
655
656 token, err := authCfg.cfg.Get([]string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey})
657 require.NoError(t, err)
658 require.Equal(t, "gho_token", token)
659}
660
661func TestSwitchUserActivatesRefreshableCredential(t *testing.T) {
662 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