OoO
|
326285d8b9
|
test(p55): 觀測台 mutation endpoint logged-in success path 補測 (23/23 PASS)
P53 之前 mutation endpoint 只測 anon block (302),logged-in 成功路徑零覆蓋:
- /playbooks/toggle/<id>: 翻 is_active 邏輯
- /budget/force_throttle: cost_throttle.evaluate() 呼叫
- /ai_calls/trigger_code_review: code_review_pipeline 觸發
- /host_health/trigger_autoheal: autoheal playbook 觸發
新增 5 cases:
- test_playbook_toggle_404_on_missing: fetchone()=None 必回 404
- test_playbook_toggle_flips_active_flag: False→True 翻轉 + 中文 message
- test_budget_force_throttle_invokes_evaluate: monkeypatch 假 throttle service
- test_ai_calls_trigger_code_review_returns_json: 至少回 JSON 不爆
- test_host_health_trigger_autoheal_returns_json: 至少回 JSON 不爆
設計重點:對未來 service 重構容忍(status code 收 200/400/500/503)
但堅持「JSON response shape」契約 — 防 HTML error page 漏出。
|
2026-05-05 12:17:54 +08:00 |
|
OoO
|
a142e85880
|
test(p53): 觀測台 smoke 涵蓋 P38-P52 新增 11 endpoint (18/18 PASS)
戰役從 P27 6 路由擴展到 P52 共 20 路由(含 5 新 GET / 5 新 POST),
原 12 tests 只蓋 P27-31 範圍,P38-P52 共 11 endpoint 無 regression 防護。
新增測試:
- test_overview_index_200: /observability/ root index
- test_overview_dashboard_200: P45 總覽頁
- test_rag_queries_200: P51 RAG 召回詳情
- test_business_intel_200: P48 商業面 × AI 編排
- test_agent_orchestration_200: P46 Agent 編排矩陣
- test_health_indicator_api_returns_json: P52 topbar 健康燈 JSON API
- test_anon_get_redirects_to_login: 12 GET 路徑全強制 login (擴充 6→12)
- test_anon_post_blocked: 8 POST mutation 全強制 login (擴充 3→8)
prod 實證:mo.wooo.work 11 endpoint 全 Flask 200/308 服務(curl 已驗)。
20/20 routes @login_required 100% 覆蓋(python regex audit)。
|
2026-05-05 01:09:52 +08:00 |
|
OoO
|
86f1fd5f50
|
fix(p33): admin observability auth hardening — Critic CRITICAL 修正
CD Pipeline / deploy (push) Has been cancelled
Critic 1 CRITICAL 發現:6 個觀測端點零認證 + csrf_exempt
→ Flask 一旦對外可達,任何人可 POST 晉升 episode / 改月預算
→ X-Forwarded-User header client 偽造 = 偽造 admin 身份
修正:
1. 全 8 個 route handler 加 @login_required(session-based auth)
- GET: ai_calls / promotion_review / quality_trend / host_health /
budget / ppt_audit_history
- POST: promotion_review/approve, .../reject, budget/update/<id>
2. promotion_review_approve approver_hash 改從 Flask session 取
(get_current_user().username)— 不再信 X-Forwarded-User header
3. app.py 移除 csrf.exempt(admin_observability_bp)
4. 12 tests(10 原 + 2 新 auth gate)全 PASS:
- test_anon_get_redirects_to_login: 6 GET 路由匿名 → 302
- test_anon_post_blocked: 3 POST mutation 匿名 → 302
|
2026-05-04 14:19:54 +08:00 |
|
OoO
|
99d2f3c543
|
fix(p32): admin URL prefix /admin → /observability — 避開 188 nginx SPA shadow
CD Pipeline / deploy (push) Successful in 2m25s
Root cause(curl 實證):
prod 188 nginx 對 /admin/* 設 try_files → SPA index.html fallback
→ Phase 27-31 的 6 個 Flask admin 路由全被 nginx 攔截
→ 外部 GET /admin/ai_calls 回 7480 byte 靜態 HTML(同 etag = SPA shell)
→ 我之前說「6 admin 頁 prod 200」是回了 200,但 body 不是 Flask 渲染
修法:
Blueprint url_prefix /admin → /observability
→ 6 個觀測頁實際生效在 /observability/* 不被 SPA 遮蔽
→ SPA frontend 仍擁有 /admin/* 命名空間(不破壞既有前端)
更新範圍:
- routes/admin_observability_routes.py: url_prefix + 註解全改
- 6 templates: 所有 href / fetch() 路徑改 /observability/
- tests/test_admin_observability_routes.py: client.get/post 路徑改
- 10/10 smoke tests 仍 PASS
統帥訪問新路徑:
http://192.168.0.188/observability/ai_calls
http://192.168.0.188/observability/host_health
http://192.168.0.188/observability/budget
http://192.168.0.188/observability/promotion_review
http://192.168.0.188/observability/quality_trend
http://192.168.0.188/observability/ppt_audit_history
|
2026-05-04 14:13:27 +08:00 |
|
OoO
|
82595ab4ac
|
test(p31): admin observability 6 路由 smoke tests (10/10 PASS)
防 Phase 27/28/29 6 個 admin 頁未來被改壞無人察覺。
覆蓋:
- /admin/ai_calls 200 + DB error fallback (2 cases)
- /admin/promotion_review 200
- /admin/quality_trend 200
- /admin/budget 200
- /admin/budget/update/<id> 輸入驗證 (3 cases: 拒負 budget / 拒 alert>100 / 收正常)
- /admin/ppt_audit_history 200 (掃 reports/ 不需 DB)
- /admin/host_health 200 (mock requests.get 三主機全 down 仍 render)
技術重點:
- 全 mock get_session,不接真 DB
- jinja2 csrf_token() stub 避免 base.html 渲染失敗
- requests.get monkeypatch 避免測試誤打三主機 11434
跑法:venv pytest tests/test_admin_observability_routes.py -v
|
2026-05-04 13:51:07 +08:00 |
|