1+ import { accessTokenManager } from '../../../src/app/authentication/context/access-token-manager' ;
2+
13const mockBasePath = '/mock/base/path' ;
24const mockApiBaseUrl = 'http://test-api-url' ;
35const mockTools = {
@@ -16,6 +18,7 @@ const mockTools = {
1618const systemMock = {
1719 get : jest . fn ( ) ,
1820 getOrThrow : jest . fn ( ) ,
21+ getNumber : jest . fn ( ) ,
1922} ;
2023
2124const loggerMock = {
@@ -27,8 +30,18 @@ const networkUtlsMock = {
2730 getInternalApiUrl : jest . fn ( ) ,
2831} ;
2932
30- const createMcpClientMock = jest . fn ( ) ;
3133
34+ const generateServiceTokenMock = jest . fn ( ) ;
35+ jest . mock (
36+ '../../../src/app/authentication/context/access-token-manager' ,
37+ ( ) => ( {
38+ accessTokenManager : {
39+ generateServiceToken : generateServiceTokenMock ,
40+ } ,
41+ } ) ,
42+ ) ;
43+
44+ const createMcpClientMock = jest . fn ( ) ;
3245jest . mock ( 'ai' , ( ) => ( {
3346 experimental_createMCPClient : createMcpClientMock ,
3447} ) ) ;
@@ -205,7 +218,7 @@ describe('getOpenOpsTools', () => {
205218 'utf-8' ,
206219 ) ;
207220
208- await getOpenOpsTools ( mockApp , 'auth-2 ' ) ;
221+ await getOpenOpsTools ( mockApp , 'auth-1 ' ) ;
209222 expect ( fs . writeFile ) . toHaveBeenCalledTimes ( 1 ) ;
210223 } ) ;
211224
@@ -214,6 +227,7 @@ describe('getOpenOpsTools', () => {
214227 tools : jest . fn ( ) . mockResolvedValue ( mockTools ) ,
215228 } ;
216229 createMcpClientMock . mockResolvedValue ( mockClient ) ;
230+ generateServiceTokenMock . mockResolvedValue ( 'auth-service-token' ) ;
217231
218232 const result = await getOpenOpsTools ( mockApp , 'test-auth-token' ) ;
219233
@@ -229,7 +243,7 @@ describe('getOpenOpsTools', () => {
229243 args : [ `${ mockBasePath } /main.py` ] ,
230244 env : expect . objectContaining ( {
231245 OPENAPI_SCHEMA_PATH : expect . any ( String ) ,
232- AUTH_TOKEN : 'test- auth-token' ,
246+ AUTH_TOKEN : 'auth-service -token' ,
233247 API_BASE_URL : mockApiBaseUrl ,
234248 OPENOPS_MCP_SERVER_PATH : mockBasePath ,
235249 LOGZIO_TOKEN : 'test-logzio-token' ,
0 commit comments