File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-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,26 @@ 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
+ console . log ( 'expireOn' , expireOn )
175
+ config . loadFromClusterAndUser (
176
+ { skipTLSVerify : false } as Cluster ,
177
+ {
178
+ authProvider : {
179
+ name : 'azure' ,
180
+ config : {
181
+ 'access-token' : 'token' ,
182
+ 'expires-on' : expireOn . toString ( ) ,
183
+ } ,
184
+ } ,
185
+ } as User ,
186
+ ) ;
187
+ const opts = { } as requestlib . Options ;
188
+ await config . applyToRequest ( opts ) ;
189
+ } ) ;
190
+
171
191
it ( 'should exec with expired token' , async ( ) => {
172
192
// TODO: fix this test for Windows
173
193
if ( process . platform === 'win32' ) {
You can’t perform that action at this time.
0 commit comments