@@ -85,6 +85,7 @@ import { fileGetContentTool } from '@/tools/file/get'
8585import { fileFetchTool } from '@/tools/file/parser'
8686import { buildFunctionExecuteBody , functionExecuteTool } from '@/tools/function/execute'
8787import { searchUsersV2Tool } from '@/tools/github/search_users'
88+ import { httpRequestTool , webhookRequestTool } from '@/tools/http'
8889import { jamaDeleteItemTool } from '@/tools/jama/delete_item'
8990import { jamaDeleteRelationshipTool } from '@/tools/jama/delete_relationship'
9091import { memoryAddTool } from '@/tools/memory/add'
@@ -5528,6 +5529,49 @@ describe('Internal Route Trust', () => {
55285529 } )
55295530} )
55305531
5532+ describe ( 'HTTP tools report the real HTTP outcome' , ( ) => {
5533+ const stubbedHttpRequestTool = tools . http_request
5534+
5535+ beforeEach ( ( ) => {
5536+ Object . assign ( tools , { http_request : httpRequestTool , webhook_request : webhookRequestTool } )
5537+ mockValidateUrlWithDNS . mockResolvedValue ( { isValid : true , resolvedIP : '93.184.216.34' } )
5538+ } )
5539+
5540+ afterEach ( ( ) => {
5541+ vi . resetAllMocks ( )
5542+ tools . http_request = stubbedHttpRequestTool
5543+ Reflect . deleteProperty ( tools , 'webhook_request' )
5544+ } )
5545+
5546+ it . each ( [
5547+ [ 'http_request' , { url : 'https://api.example.com/orders' , method : 'POST' , body : { } } ] ,
5548+ [ 'webhook_request' , { url : 'https://api.example.com/hooks' , body : { } } ] ,
5549+ ] ) (
5550+ '%s treats a 200 whose body has top-level status and data as a success' ,
5551+ async ( toolId , params ) => {
5552+ mockSecureFetchWithPinnedIP . mockResolvedValueOnce (
5553+ toSecureFetchResponse (
5554+ Response . json (
5555+ { status : 'success' , data : { orderId : 'A-1001' } } ,
5556+ { headers : { 'x-request-id' : 'req-123' } }
5557+ )
5558+ )
5559+ )
5560+
5561+ const result = await executeTool ( toolId , params , { skipPostProcess : true } )
5562+
5563+ expect ( result , result . error ) . toMatchObject ( {
5564+ success : true ,
5565+ output : {
5566+ status : 200 ,
5567+ data : { status : 'success' , data : { orderId : 'A-1001' } } ,
5568+ headers : expect . objectContaining ( { 'x-request-id' : 'req-123' } ) ,
5569+ } ,
5570+ } )
5571+ }
5572+ )
5573+ } )
5574+
55315575describe ( 'File Parameter Normalization' , ( ) => {
55325576 let cleanupEnvVars : ( ) => void
55335577
0 commit comments