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

Function simulateRefreshTokenExpired

internal/config/refreshable.go:385–392  ·  view source on GitHub ↗

simulateRefreshTokenExpired simulates refresh token expiry when a debug lifetime override is set. The override is anchored at issuance, computed from the stored expiry and lifetime. Without an override it always returns false; real expiry is detected from the server's rejection.

(credential gh.Credential, now time.Time)

Source from the content-addressed store, hash-verified

383// The override is anchored at issuance, computed from the stored expiry and lifetime.
384// Without an override it always returns false; real expiry is detected from the server's rejection.
385func simulateRefreshTokenExpired(credential gh.Credential, now time.Time) bool {
386 if lifetime, ok := debug.Config().RefreshTokenExpiresIn.Value(); ok && credential.RefreshTokenExpiresAt != nil {
387 issuedAt := credential.RefreshTokenExpiresAt.Add(-time.Duration(credential.RefreshTokenExpiresIn) * time.Second)
388 expiresAt := issuedAt.Add(lifetime)
389 return !now.Before(expiresAt)
390 }
391 return false
392}
393
394// credentialFromRefreshable projects a renewed RefreshableCredential onto the universal gh.Credential shape, tagging it
395// with the given source. Timestamps are cloned so the result never aliases the input's *time.Time values.

Callers 1

Calls 4

ConfigFunction · 0.92
ValueMethod · 0.80
DurationMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected