Files
agent-safe-middleware/tests/scenarios/example.json
T
starrrLight b583d89b39 feat(测试): 增加 JSON 场景运行器
支持 SSE、普通 POST 和文件上传场景,通过真实中间层路径匹配和插件生命周期执行。

补充场景校验、临时上游、文件转发断言、示例 JSON、测试和文档。
2026-10-15 23:51:31 +08:00

72 lines
1.9 KiB
JSON

{
"scenarios": [
{
"id": "chat-stream",
"kind": "sse",
"path": "/chat/stream?trace=demo",
"headers": {
"content-type": "application/json",
"x-test": "sse"
},
"body": {
"message": "你好",
"messages": [{"role": "user", "content": "你好"}]
},
"response": {
"status": 200,
"headers": {"content-type": "text/event-stream"},
"events": [
{"event": "run_started", "id": "1", "data": {"data": {"status": "started"}}},
{"event": "text_delta", "id": "2", "data": {"data": {"content": "安全内容"}}},
{"event": "run_completed", "id": "3", "data": {"data": {"status": "success"}}}
]
},
"expect": {
"status": 200,
"events": ["run_started", "text_delta", "run_completed"],
"upstream_path": "/chat/stream?trace=demo"
}
},
{
"id": "ordinary-post",
"kind": "post",
"path": "/api/echo",
"headers": {"content-type": "application/json"},
"body": {"message": "普通请求"},
"response": {
"status": 200,
"headers": {"content-type": "application/json"},
"body": {"ok": true}
},
"expect": {
"status": 200,
"body": {"ok": true},
"upstream_path": "/api/echo"
}
},
{
"id": "text-upload",
"kind": "file",
"path": "/upload?source=test",
"headers": {"x-test": "upload"},
"file": {
"field": "file",
"path": "fixtures/sample.txt",
"filename": "sample.txt",
"mime": "text/plain"
},
"response": {
"status": 200,
"headers": {"content-type": "application/json"},
"body": {"stored": true}
},
"expect": {
"status": 200,
"body": {"stored": true},
"upstream_path": "/upload?source=test",
"file_forwarded": true
}
}
]
}