阶段4(下):LangChain 1.x、提示词与注入防护、模型侧(路由/vLLM/LoRA)、AI 编程工具与验证、Dify/Coze 专题
This commit is contained in:
1 parent
caaec830b3
commit
7a32d2c9a6
38 files changed
+3059
-67
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# requires: fastapi, httpx, pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from app import app
|
||||
|
||||
c = TestClient(app)
|
||||
H = {"Authorization": "Bearer dev-only-key"}
|
||||
|
||||
|
||||
def test_openapi_has_operation_and_server():
|
||||
spec = c.get("/openapi.json").json()
|
||||
op = spec["paths"]["/orders/{order_id}"]["get"]
|
||||
assert op["operationId"] == "getOrderStatus" and spec["servers"][0]["url"].startswith("http")
|
||||
assert "HTTPBearer" in spec["components"]["securitySchemes"]
|
||||
|
||||
|
||||
def test_auth_and_isolation():
|
||||
assert c.get("/orders/A1001").status_code in (401, 403)
|
||||
assert c.get("/orders/A1001", headers={"Authorization": "Bearer wrong"}).status_code == 401
|
||||
assert c.get("/orders/A1001", headers=H).json()["status"] == "已发货"
|
||||
assert c.get("/orders/A1002", headers=H).status_code == 404 # 其他店铺的订单
|
||||
Reference in new issue
Block a user