File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -57,7 +57,8 @@ export class AzureAuth implements Authenticator {
57
57
return false ;
58
58
}
59
59
60
- const expiration = expiry ? Date . parse ( expiry ) : new Date ( parseInt ( expiresOn ! , 10 ) ) ;
60
+ const expiresOnDate = expiresOn ? new Date ( parseInt ( expiresOn , 10 ) * 1000 ) : undefined ;
61
+ const expiration = expiry ? Date . parse ( expiry ) : expiresOnDate ! ;
61
62
if ( expiration < Date . now ( ) ) {
62
63
return true ;
63
64
}
Original file line number Diff line number Diff line change @@ -168,6 +168,25 @@ describe('AzureAuth', () => {
168
168
return expect ( config . applyToRequest ( opts ) ) . to . eventually . be . rejectedWith ( / F a i l e d t o r e f r e s h t o k e n / ) ;
169
169
} ) ;
170
170
171
+ it ( 'should exec when no cmd and token is not expired' , async ( ) => {
172
+ const config = new KubeConfig ( ) ;
173
+ const expireOn = new Date ( ) . getTime ( ) / 1000 + 1000 ;
174
+ config . loadFromClusterAndUser (
175
+ { skipTLSVerify : false } as Cluster ,
176
+ {
177
+ authProvider : {
178
+ name : 'azure' ,
179
+ config : {
180
+ 'access-token' : 'token' ,
181
+ 'expires-on' : expireOn . toString ( ) ,
182
+ } ,
183
+ } ,
184
+ } as User ,
185
+ ) ;
186
+ const opts = { } as requestlib . Options ;
187
+ await config . applyToRequest ( opts ) ;
188
+ } ) ;
189
+
171
190
it ( 'should exec with expired token' , async ( ) => {
172
191
// TODO: fix this test for Windows
173
192
if ( process . platform === 'win32' ) {
You can’t perform that action at this time.
0 commit comments