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

Function TestLoginRefreshablePurgesNonExpiringLogin

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

Source from the content-addressed store, hash-verified

601}
602
603func TestLoginRefreshablePurgesNonExpiringLogin(t *testing.T) {
604 authCfg := newTestAuthConfig(t)
605
606 // A prior non-expiring login persists a token to disk so the reload observes it.
607 _, err := authCfg.Login("github.com", "test-user", "stale-token", "ssh", false)
608 require.NoError(t, err)
609
610 credential := gh.Credential{Token: "access", RefreshToken: "refresh"}
611 _, err = authCfg.LoginRefreshable("github.com", "test-user", credential, "ssh", false)
612 require.NoError(t, err)
613
614 // The stale non-expiring token is gone and the refreshable credential resolves instead.
615 requireNoKey(t, authCfg.cfg, []string{hostsKey, "github.com", usersKey, "test-user", oauthTokenKey})
616 cred, err := authCfg.TokenForUser("github.com", "test-user")
617 require.NoError(t, err)
618 require.Equal(t, "access", cred.Token)
619}
620
621// TestLoginRefreshablePurgesNonExpiringKeyringLogin covers the keyring arm of the non-expiring purge. Resolution now
622// 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