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 {
5757 return false ;
5858 }
5959
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 ! ;
6162 if ( expiration < Date . now ( ) ) {
6263 return true ;
6364 }
Original file line number Diff line number Diff line change @@ -168,6 +168,25 @@ describe('AzureAuth', () => {
168168 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 / ) ;
169169 } ) ;
170170
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+
171190 it ( 'should exec with expired token' , async ( ) => {
172191 // TODO: fix this test for Windows
173192 if ( process . platform === 'win32' ) {
You can’t perform that action at this time.
0 commit comments