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)
| 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. |
| 384 | func 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. |
no test coverage detected