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

Function TestLoginRefreshablePurgesNonExpiringLogin

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

Source from the content-addressed store, hash-verified

762}
763
764func TestLoginRefreshablePurgesNonExpiringLogin(t *testing.T) {
765 authCfg := newTestAuthConfig(t)
766
767 // A prior non-expiring login persists a token to disk so the reload observes it.
768 _, err := authCfg.Login("github.com", "test-user", "stale-token", "ssh", false)
769 require.NoError(t, err)
770
771 credential := gh.Credential{Token: "access", RefreshToken: "refresh"}
772 _, err = authCfg.LoginRefreshable("github.com", "test-user", credential, "ssh", false)
773 require.NoError(t, err)
774
775 // The stale non-expiring token is gone and the refreshable credential resolves instead.
776 requireNoKey(t, authCfg.cfg, []string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey})
777 cred, err := authCfg.TokenForUser("github.com", "test-user")
778 require.NoError(t, err)
779 require.Equal(t, "access", cred.Token)
780}
781
782// TestLoginRefreshablePurgesNonExpiringKeyringLogin covers the keyring arm of the non-expiring purge. Resolution now
783// probes the ordinary keyring before the refreshable credential, so a stale per-user keyring token left behind would

Callers

nothing calls this directly

Calls 6

newTestAuthConfigFunction · 0.85
EqualMethod · 0.80
requireNoKeyFunction · 0.70
LoginMethod · 0.65
LoginRefreshableMethod · 0.65
TokenForUserMethod · 0.65

Tested by

no test coverage detected