@@ -185,13 +185,13 @@ type RefreshTokenPolicy struct {
185185 validIfNotUsedFor time.Duration // interval from last token update to the end of its life
186186 reuseInterval time.Duration // interval within which old refresh token is allowed to be reused
187187
188- Clock func () time.Time
188+ now func () time.Time
189189
190190 logger log.Logger
191191}
192192
193- func NewRefreshTokenPolicyFromConfig (logger log.Logger , rotation bool , validIfNotUsedFor , absoluteLifetime , reuseInterval string ) (* RefreshTokenPolicy , error ) {
194- r := RefreshTokenPolicy {Clock : time .Now , logger : logger }
193+ func NewRefreshTokenPolicy (logger log.Logger , rotation bool , validIfNotUsedFor , absoluteLifetime , reuseInterval string ) (* RefreshTokenPolicy , error ) {
194+ r := RefreshTokenPolicy {now : time .Now , logger : logger }
195195 var err error
196196
197197 if validIfNotUsedFor != "" {
@@ -231,19 +231,19 @@ func (r *RefreshTokenPolicy) CompletelyExpired(lastUsed time.Time) bool {
231231 if r .absoluteLifetime == 0 {
232232 return false // expiration disabled
233233 }
234- return r .Clock ().After (lastUsed .Add (r .absoluteLifetime ))
234+ return r .now ().After (lastUsed .Add (r .absoluteLifetime ))
235235}
236236
237237func (r * RefreshTokenPolicy ) ExpiredBecauseUnused (lastUsed time.Time ) bool {
238238 if r .validIfNotUsedFor == 0 {
239239 return false // expiration disabled
240240 }
241- return r .Clock ().After (lastUsed .Add (r .validIfNotUsedFor ))
241+ return r .now ().After (lastUsed .Add (r .validIfNotUsedFor ))
242242}
243243
244244func (r * RefreshTokenPolicy ) AllowedToReuse (lastUsed time.Time ) bool {
245245 if r .reuseInterval == 0 {
246246 return false // expiration disabled
247247 }
248- return ! r .Clock ().After (lastUsed .Add (r .reuseInterval ))
248+ return ! r .now ().After (lastUsed .Add (r .reuseInterval ))
249249}
0 commit comments