@@ -41,9 +41,14 @@ const metric = {
4141}
4242const cases = [
4343 [ 'list_metrics' , { compartmentId : 'compartment' } ] ,
44- [ 'summarize_metrics_data' , {
45- compartmentId : 'compartment' , namespace : 'my_app' , query : 'Requests[1m].mean()' ,
46- } ] ,
44+ [
45+ 'summarize_metrics_data' ,
46+ {
47+ compartmentId : 'compartment' ,
48+ namespace : 'my_app' ,
49+ query : 'Requests[1m].mean()' ,
50+ } ,
51+ ] ,
4752 [ 'post_metric_data' , { metricData : [ metric ] } ] ,
4853 [ 'list_alarms' , { compartmentId : 'compartment' } ] ,
4954 [ 'list_alarms_status' , { compartmentId : 'compartment' } ] ,
@@ -53,10 +58,15 @@ const cases = [
5358 [ 'create_alarm' , alarm ] ,
5459 [ 'update_alarm' , { alarmId : 'alarm' , isEnabled : false } ] ,
5560 [ 'delete_alarm' , { alarmId : 'alarm' } ] ,
56- [ 'create_alarm_suppression' , {
57- alarmId : 'alarm' , displayName : 'Maintenance' ,
58- timeSuppressFrom : '2026-09-05T12:00:00Z' , timeSuppressUntil : '2026-09-05T13:00:00Z' ,
59- } ] ,
61+ [
62+ 'create_alarm_suppression' ,
63+ {
64+ alarmId : 'alarm' ,
65+ displayName : 'Maintenance' ,
66+ timeSuppressFrom : '2026-09-05T12:00:00Z' ,
67+ timeSuppressUntil : '2026-09-05T13:00:00Z' ,
68+ } ,
69+ ] ,
6070 [ 'list_alarm_suppressions' , { alarmId : 'alarm' } ] ,
6171 [ 'get_alarm_suppression' , { alarmSuppressionId : 'suppression' } ] ,
6272 [ 'delete_alarm_suppression' , { alarmSuppressionId : 'suppression' } ] ,
@@ -71,7 +81,8 @@ function request(overrides: Partial<InternalToolOperationCall> = {}): InternalTo
7181 input : { ...connection , compartmentId : 'compartment' } ,
7282 headers : new Headers ( ) ,
7383 context : {
74- userId : 'trusted-user' , workspaceId : 'trusted-workspace' ,
84+ userId : 'trusted-user' ,
85+ workspaceId : 'trusted-workspace' ,
7586 workflowId : 'trusted-workflow' ,
7687 } ,
7788 requestId : 'request' ,
@@ -83,23 +94,30 @@ describe('OCI Monitoring internal dispatcher', () => {
8394 beforeEach ( ( ) => {
8495 vi . clearAllMocks ( )
8596 mocks . authorize . mockResolvedValue ( {
86- ok : true , resolvedCredentialId : 'authorized-credential' , credentialType : 'service_account' ,
97+ ok : true ,
98+ resolvedCredentialId : 'authorized-credential' ,
99+ credentialType : 'service_account' ,
87100 } )
88101 mocks . createClient . mockResolvedValue ( client )
89102 mocks . execute . mockResolvedValue ( { success : true , output : { opcRequestId : 'oracle-request' } } )
90103 } )
91104
92105 it . each ( cases ) ( 'authorizes and dispatches %s with cancellation' , async ( operation , input ) => {
93106 const controller = new AbortController ( )
94- const response = await executeOciMonitoringTool ( request ( {
95- toolId : `oci_monitoring_${ operation } ` ,
96- input : { ...connection , ...input } ,
97- signal : controller . signal ,
98- } ) )
107+ const response = await executeOciMonitoringTool (
108+ request ( {
109+ toolId : `oci_monitoring_${ operation } ` ,
110+ input : { ...connection , ...input } ,
111+ signal : controller . signal ,
112+ } )
113+ )
99114
100115 expect ( response . status ) . toBe ( 200 )
101116 expect ( mocks . execute ) . toHaveBeenCalledWith (
102- client , operation , expect . objectContaining ( input ) , controller . signal
117+ client ,
118+ operation ,
119+ expect . objectContaining ( input ) ,
120+ controller . signal
103121 )
104122 expect ( mocks . createClient ) . toHaveBeenCalledWith ( {
105123 credentialId : 'authorized-credential' ,
@@ -110,17 +128,27 @@ describe('OCI Monitoring internal dispatcher', () => {
110128 } )
111129
112130 it ( 'uses execution identity and scope instead of forged input context' , async ( ) => {
113- await executeOciMonitoringTool ( request ( {
114- input : { ...connection , compartmentId : 'compartment' ,
115- userId : 'forged-user' , workspaceId : 'forged-workspace' , workflowId : 'forged-workflow' ,
116- resolvedCredentialId : 'forged-credential' , serviceId : 'oci_logging' } ,
117- } ) )
131+ await executeOciMonitoringTool (
132+ request ( {
133+ input : {
134+ ...connection ,
135+ compartmentId : 'compartment' ,
136+ userId : 'forged-user' ,
137+ workspaceId : 'forged-workspace' ,
138+ workflowId : 'forged-workflow' ,
139+ resolvedCredentialId : 'forged-credential' ,
140+ serviceId : 'oci_logging' ,
141+ } ,
142+ } )
143+ )
118144
119145 expect ( mocks . authorize ) . toHaveBeenCalledWith (
120146 expect . objectContaining ( { success : true , userId : 'trusted-user' } ) ,
121147 {
122- credentialId : 'requested-credential' , workspaceId : 'trusted-workspace' ,
123- workflowId : 'trusted-workflow' , callerUserId : 'trusted-user' ,
148+ credentialId : 'requested-credential' ,
149+ workspaceId : 'trusted-workspace' ,
150+ workflowId : 'trusted-workflow' ,
151+ callerUserId : 'trusted-user' ,
124152 }
125153 )
126154 expect ( mocks . execute . mock . calls [ 0 ] [ 2 ] ) . not . toHaveProperty ( 'workspaceId' )
@@ -166,26 +194,39 @@ describe('OCI Monitoring internal dispatcher', () => {
166194
167195 it ( 'preserves partial ingestion details and non-retryability' , async ( ) => {
168196 const failure = {
169- success : false , retryable : false , error : 'Rejected metric' ,
170- output : { failedMetricsCount : 1 , failedMetrics : [ { message : 'invalid' , metricData : metric } ] } ,
197+ success : false ,
198+ retryable : false ,
199+ error : 'Rejected metric' ,
200+ output : {
201+ failedMetricsCount : 1 ,
202+ failedMetrics : [ { message : 'invalid' , metricData : metric } ] ,
203+ } ,
171204 }
172205 mocks . execute . mockResolvedValueOnce ( failure )
173- const response = await executeOciMonitoringTool ( request ( {
174- toolId : 'oci_monitoring_post_metric_data' , input : { ...connection , metricData : [ metric ] } ,
175- } ) )
206+ const response = await executeOciMonitoringTool (
207+ request ( {
208+ toolId : 'oci_monitoring_post_metric_data' ,
209+ input : { ...connection , metricData : [ metric ] } ,
210+ } )
211+ )
176212 await expect ( response . json ( ) ) . resolves . toEqual ( failure )
177213 } )
178214
179215 it ( 'marks ingestion transport failures non-retryable and retains the request ID' , async ( ) => {
180216 mocks . execute . mockRejectedValueOnce (
181217 new OciClientError ( 'request_failed' , { status : 503 , opcRequestId : 'failed-request' } )
182218 )
183- const response = await executeOciMonitoringTool ( request ( {
184- toolId : 'oci_monitoring_post_metric_data' , input : { ...connection , metricData : [ metric ] } ,
185- } ) )
219+ const response = await executeOciMonitoringTool (
220+ request ( {
221+ toolId : 'oci_monitoring_post_metric_data' ,
222+ input : { ...connection , metricData : [ metric ] } ,
223+ } )
224+ )
186225 expect ( response . status ) . toBe ( 503 )
187226 await expect ( response . json ( ) ) . resolves . toMatchObject ( {
188- success : false , retryable : false , output : { opcRequestId : 'failed-request' } ,
227+ success : false ,
228+ retryable : false ,
229+ output : { opcRequestId : 'failed-request' } ,
189230 } )
190231 } )
191232
@@ -217,9 +258,13 @@ describe('OCI Monitoring internal dispatcher', () => {
217258 controller . abort ( )
218259 return { ok : true , credentialType : 'service_account' , resolvedCredentialId : 'credential' }
219260 } )
220- await expect ( executeOciMonitoringTool ( request ( {
221- signal : controller . signal ,
222- } ) ) ) . rejects . toMatchObject ( { name : 'AbortError' } )
261+ await expect (
262+ executeOciMonitoringTool (
263+ request ( {
264+ signal : controller . signal ,
265+ } )
266+ )
267+ ) . rejects . toMatchObject ( { name : 'AbortError' } )
223268 expect ( mocks . createClient ) . not . toHaveBeenCalled ( )
224269 } )
225270} )
0 commit comments