File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,9 @@ func (m *Manager) expired(t *authenticationv1.TokenRequest) bool {
168
168
// ttl, or if the token is older than 24 hours.
169
169
func (m * Manager ) requiresRefresh (tr * authenticationv1.TokenRequest ) bool {
170
170
if tr .Spec .ExpirationSeconds == nil {
171
- klog .Errorf ("expiration seconds was nil for tr: %#v" , tr )
171
+ cpy := tr .DeepCopy ()
172
+ cpy .Status .Token = ""
173
+ klog .Errorf ("expiration seconds was nil for tr: %#v" , cpy )
172
174
return false
173
175
}
174
176
now := m .clock .Now ()
Original file line number Diff line number Diff line change @@ -130,6 +130,7 @@ func TestRequiresRefresh(t *testing.T) {
130
130
cases := []struct {
131
131
now , exp time.Time
132
132
expectRefresh bool
133
+ requestTweaks func (* authenticationv1.TokenRequest )
133
134
}{
134
135
{
135
136
now : start .Add (10 * time .Minute ),
@@ -151,6 +152,15 @@ func TestRequiresRefresh(t *testing.T) {
151
152
exp : start .Add (60 * time .Minute ),
152
153
expectRefresh : true ,
153
154
},
155
+ {
156
+ // expiry will be overwritten by the tweak below.
157
+ now : start .Add (0 * time .Minute ),
158
+ exp : start .Add (60 * time .Minute ),
159
+ expectRefresh : false ,
160
+ requestTweaks : func (tr * authenticationv1.TokenRequest ) {
161
+ tr .Spec .ExpirationSeconds = nil
162
+ },
163
+ },
154
164
}
155
165
156
166
for i , c := range cases {
@@ -165,6 +175,11 @@ func TestRequiresRefresh(t *testing.T) {
165
175
ExpirationTimestamp : metav1.Time {Time : c .exp },
166
176
},
167
177
}
178
+
179
+ if c .requestTweaks != nil {
180
+ c .requestTweaks (tr )
181
+ }
182
+
168
183
mgr := NewManager (nil )
169
184
mgr .clock = clock
170
185
You can’t perform that action at this time.
0 commit comments