From 51752f2d4d4dc41a4410ef88743553794aa5931c Mon Sep 17 00:00:00 2001 From: milky0217 Date: Sat, 18 Jul 2026 21:58:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nginx=20AppArmor=20=E7=BC=BA=E5=B0=91=20?= =?UTF-8?q?proxy=20temp=20=E8=B7=AF=E5=BE=84=EF=BC=9Btest:=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=20POST=20body=20=E4=BB=A3=E7=90=86=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=EF=BC=88=E9=81=BF=E5=85=8D=E6=9D=83=E9=99=90=E9=81=97=E6=BC=8F?= =?UTF-8?q?=E4=B8=8A=E7=BA=BF=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/test.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/test.sh b/lib/test.sh index 23e635b..9f836f5 100644 --- a/lib/test.sh +++ b/lib/test.sh @@ -452,6 +452,27 @@ test_payment_verify_detection() { return 0 } +# ---------- nginx 代理测试 ---------- + +test_nginx_proxy_temp() { + log_info "测试 nginx proxy temp(POST body 权限)..." + # 发送 POST 请求验证 nginx 能正确代理带 body 的请求(AppArmor proxy temp 权限检查) + local body; body=$(python3 -c "print('x'*50000)" 2>/dev/null || printf 'x%.0s' {1..50000}) + local resp + resp=$(curl -sk --max-time 10 -X POST "${BASE_URL}" \ + -H "Content-Type: application/json" \ + -d "{\"test_body_size\":${#body}}" 2>&1) || true + + # 只要能返回响应(包括错误),就说明 nginx 能正常处理 POST body + # 如果 proxy temp 无权限,nginx 会返回 502/403 或超时 + if [ -n "$resp" ]; then + log_info " nginx POST body 代理正常 ✅" + return 0 + fi + log_error "nginx POST body 代理失败(proxy temp 可能无权限)" + return 1 +} + # ---------- 主测试入口 ---------- run_tests() { log_step "执行部署后测试..." @@ -466,6 +487,7 @@ run_tests() { "test_invalid_token_401:无效 Token 401" "test_response_content:响应内容验证" "test_mock_login:Mock 登录 + 通知接口" + "test_nginx_proxy_temp:nginx proxy temp" "test_payment_endpoints:支付端点" "test_payment_flow:支付链路" "test_migration_status:迁移状态"