11import { describe , it , expect , beforeEach , vi } from 'vitest' ;
2- import { AuthenticationManager , type AuthenticationOptions } from '../../src/authenticationManager' ;
2+ import {
3+ AuthenticationManager ,
4+ type AuthenticationOptions ,
5+ } from '../../src/authenticationManager' ;
36import * as openidClient from 'openid-client' ;
47import * as jwtDecodeModule from 'jwt-decode' ;
58import * as grpc from '@grpc/grpc-js' ;
@@ -43,7 +46,7 @@ describe('AuthenticationManager', () => {
4346 ) ;
4447 expect ( openidClient . clientCredentialsGrant ) . toHaveBeenCalledWith (
4548 mockDiscovery ,
46- { audience : 'crisp-athena-dev ' , scope : options . scope }
49+ { audience : 'crisp-athena-live ' , scope : options . scope } ,
4750 ) ;
4851 } ) ;
4952
@@ -67,7 +70,9 @@ describe('AuthenticationManager', () => {
6770 ...mockToken ,
6871 access_token : 'new_access_token' ,
6972 } ) ;
70- ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( { exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 } ) ;
73+ ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( {
74+ exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 ,
75+ } ) ;
7176
7277 const header = await manager . getAuthenticationHeader ( ) ;
7378 expect ( openidClient . refreshTokenGrant ) . toHaveBeenCalled ( ) ;
@@ -82,7 +87,9 @@ describe('AuthenticationManager', () => {
8287 ...mockToken ,
8388 access_token : 'reacquired_access_token' ,
8489 } ) ;
85- ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( { exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 } ) ;
90+ ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( {
91+ exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 ,
92+ } ) ;
8693
8794 const header = await manager . getAuthenticationHeader ( ) ;
8895 expect ( openidClient . clientCredentialsGrant ) . toHaveBeenCalled ( ) ;
@@ -93,12 +100,16 @@ describe('AuthenticationManager', () => {
93100 await manager . getAuthenticationHeader ( ) ;
94101 ( manager as any ) . tokenExpiration = new Date ( Date . now ( ) - 1000 ) ; // expired
95102 ( manager as any ) . token . refresh_token = 'mock_refresh_token' ;
96- ( openidClient . refreshTokenGrant as any ) . mockRejectedValue ( new Error ( 'refresh failed' ) ) ;
103+ ( openidClient . refreshTokenGrant as any ) . mockRejectedValue (
104+ new Error ( 'refresh failed' ) ,
105+ ) ;
97106 ( openidClient . clientCredentialsGrant as any ) . mockResolvedValue ( {
98107 ...mockToken ,
99108 access_token : 'fallback_access_token' ,
100109 } ) ;
101- ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( { exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 } ) ;
110+ ( jwtDecodeModule . jwtDecode as any ) . mockReturnValue ( {
111+ exp : Math . floor ( Date . now ( ) / 1000 ) + 3600 ,
112+ } ) ;
102113
103114 const header = await manager . getAuthenticationHeader ( ) ;
104115 expect ( openidClient . refreshTokenGrant ) . toHaveBeenCalled ( ) ;
0 commit comments