@@ -18,6 +18,13 @@ vi.mock('@/lib/internal/oci-compute/operations', () => ({
1818} ) )
1919
2020import { executeOciComputeTool } from '@/lib/internal/oci-compute/execute-tool'
21+ import { OciComputeBlock } from '@/blocks/blocks/oci_compute'
22+ import { ociComputeListImagesTool } from '@/tools/oci_compute/list_images'
23+ import { ociComputeListInstanceConfigurationsTool } from '@/tools/oci_compute/list_instance_configurations'
24+ import { ociComputeListInstancePoolsTool } from '@/tools/oci_compute/list_instance_pools'
25+ import { ociComputeListInstancesTool } from '@/tools/oci_compute/list_instances'
26+ import { ociComputeListShapesTool } from '@/tools/oci_compute/list_shapes'
27+ import { ociComputeListSubnetsTool } from '@/tools/oci_compute/list_subnets'
2128
2229function call ( overrides : Partial < InternalToolOperationCall > = { } ) : InternalToolOperationCall {
2330 return {
@@ -42,6 +49,85 @@ beforeEach(() => {
4249} )
4350
4451describe ( 'OCI Compute trusted execution wiring' , ( ) => {
52+ it . each ( [
53+ ociComputeListInstancesTool ,
54+ ociComputeListImagesTool ,
55+ ociComputeListShapesTool ,
56+ ociComputeListSubnetsTool ,
57+ ociComputeListInstanceConfigurationsTool ,
58+ ociComputeListInstancePoolsTool ,
59+ ] ) ( 'normalizes native blank discovery filters for $id' , async ( tool ) => {
60+ for ( const blank of [ null , '' , undefined ] ) {
61+ const raw = {
62+ operation : tool . id ,
63+ oauthCredential : 'submitted' ,
64+ region : 'us-ashburn-1' ,
65+ compartmentId : 'compartment' ,
66+ limit : '10' ,
67+ page : blank ,
68+ sortBy : blank ,
69+ sortOrder : blank ,
70+ displayName : blank ,
71+ availabilityDomain : blank ,
72+ lifecycleState : blank ,
73+ capacityReservationId : blank ,
74+ operatingSystemVersion : blank ,
75+ shape : blank ,
76+ imageId : blank ,
77+ vcnId : blank ,
78+ }
79+ const params = { ...raw , ...OciComputeBlock . tools . config ?. params ?.( raw ) }
80+ const response = await executeOciComputeTool (
81+ call ( { toolId : tool . id , input : tool . operation . input ( params ) } )
82+ )
83+ expect ( response . status ) . toBe ( 200 )
84+ expect ( mocks . execute ) . toHaveBeenLastCalledWith (
85+ expect . anything ( ) ,
86+ tool . id . replace ( 'oci_compute_' , '' ) ,
87+ expect . objectContaining ( { compartmentId : 'compartment' , limit : 10 } ) ,
88+ undefined
89+ )
90+ expect ( mocks . execute . mock . lastCall ?. [ 2 ] . page ) . toBeUndefined ( )
91+ }
92+ } )
93+
94+ it ( 'keeps meaningful zero, false and empty mutation values while rejecting invalid list input' , async ( ) => {
95+ const raw = {
96+ operation : 'oci_compute_update_instance' ,
97+ capacityReservationId : '' ,
98+ preserveBootVolume : false ,
99+ }
100+ const params = { ...raw , ...OciComputeBlock . tools . config ?. params ?.( raw ) }
101+ expect ( params . capacityReservationId ) . toBe ( '' )
102+ const resized = OciComputeBlock . tools . config ?. params ?.( {
103+ operation : 'oci_compute_update_instance_pool' ,
104+ size : 0 ,
105+ } )
106+ expect ( resized ?. size ) . toBe ( 0 )
107+ const terminated = OciComputeBlock . tools . config ?. params ?.( {
108+ operation : 'oci_compute_terminate_instance' ,
109+ preserveBootVolume : false ,
110+ } )
111+ expect ( terminated ?. preserveBootVolume ) . toBe ( false )
112+ const invalid = {
113+ operation : ociComputeListInstancesTool . id ,
114+ oauthCredential : 'submitted' ,
115+ region : 'us-ashburn-1' ,
116+ compartmentId : 'compartment' ,
117+ page : 12 ,
118+ }
119+ const response = await executeOciComputeTool (
120+ call ( {
121+ toolId : ociComputeListInstancesTool . id ,
122+ input : ociComputeListInstancesTool . operation . input ( {
123+ ...invalid ,
124+ ...OciComputeBlock . tools . config ?. params ?.( invalid ) ,
125+ } ) ,
126+ } )
127+ )
128+ expect ( response . status ) . toBe ( 400 )
129+ expect ( mocks . execute ) . not . toHaveBeenCalled ( )
130+ } )
45131 it ( 'authorizes submitted identity and binds only the resolved credential and trusted scope' , async ( ) => {
46132 const signal = new AbortController ( ) . signal
47133 expect ( ( await executeOciComputeTool ( call ( { signal } ) ) ) . status ) . toBe ( 200 )
0 commit comments