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 {
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,26 @@ 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+ 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+
171191 it ( 'should exec with expired token' , async ( ) => {
172192 // TODO: fix this test for Windows
173193 if ( process . platform === 'win32' ) {
You can’t perform that action at this time.
0 commit comments