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

Function simulateRefreshTokenExpired

internal/config/refreshable.go:384–391  ·  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

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