path string
issuer string
http *http.Client
- clock func() time.Time
}
// tokenFile is the content of the token file.
path: path,
issuer: issuer,
http: &http.Client{},
- clock: time.Now,
}
}
}
expiry, found := tokenExpiry(tokens.AccessToken)
- if !found || !a.clock().Before(expiry.Add(-refreshMargin)) {
+ if !found || !time.Now().Before(expiry.Add(-refreshMargin)) {
tokens, err = a.refresh(ctx, tokens)
if err != nil {
return err