File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
pkg/platform/authentication Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ func (s *Auth) MaybeRenew() error {
148148// cutoffReached checks whether the JWT will expire before the provided cutoff time
149149func (s * Auth ) cutoffReached (cutoff time.Time ) bool {
150150 expires := s .lastRenewal .Add (s .jwtLifetime )
151- return expires .Before (cutoff )
151+ return expires .Equal ( cutoff ) || expires . Before (cutoff )
152152}
153153
154154func (s * Auth ) Close () error {
Original file line number Diff line number Diff line change 88)
99
1010func TestAuth_cutoffReached (t * testing.T ) {
11+ now := time .Now ()
12+
1113 tests := []struct {
1214 name string
1315 auth * Auth
@@ -17,28 +19,28 @@ func TestAuth_cutoffReached(t *testing.T) {
1719 {
1820 "Cutoff one second beyond keepalive" ,
1921 & Auth {
20- lastRenewal : ptr .To (time . Now () ),
22+ lastRenewal : ptr .To (now ),
2123 jwtLifetime : time .Second ,
2224 },
23- time . Now () .Add (2 * time .Second ),
25+ now .Add (2 * time .Second ),
2426 true ,
2527 },
2628 {
2729 "Cutoff one second before keepalive" ,
2830 & Auth {
29- lastRenewal : ptr .To (time . Now () ),
31+ lastRenewal : ptr .To (now ),
3032 jwtLifetime : 2 * time .Second ,
3133 },
32- time . Now () .Add (time .Second ),
34+ now .Add (time .Second ),
3335 false ,
3436 },
3537 {
3638 "Cutoff equal to keepalive" ,
3739 & Auth {
38- lastRenewal : ptr .To (time . Now () ),
40+ lastRenewal : ptr .To (now ),
3941 jwtLifetime : time .Second ,
4042 },
41- time . Now () .Add (time .Second ),
43+ now .Add (time .Second ),
4244 true ,
4345 },
4446 }
You can’t perform that action at this time.
0 commit comments