Files
wecom-ai-assistant/deploy/scripts/acceptance.sh
2026-02-05 16:36:32 +08:00

33 lines
1.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 最小闭环验收脚本:健康检查、登录、可选回调验签
# 用法: BASE_URL=http://localhost ./acceptance.sh 或 BASE_URL=https://your-domain.com ./acceptance.sh
set -e
BASE_URL="${BASE_URL:-http://localhost}"
echo "=== 1. Health ==="
r=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/api/health")
if [ "$r" != "200" ]; then
echo "FAIL health: got $r"
exit 1
fi
echo "OK"
echo "=== 2. Login ==="
login=$(curl -s -X POST "$BASE_URL/api/auth/login" -H "Content-Type: application/json" -d '{"username":"admin","password":"admin"}')
code=$(echo "$login" | grep -o '"code":[0-9]*' | cut -d: -f2)
if [ "$code" != "0" ]; then
echo "FAIL login: $login"
exit 1
fi
echo "OK"
echo "=== 3. WeCom callback GET (验签需正确 Token/Key此处仅检查 200 或 400) ==="
wecom_get=$(curl -s -o /dev/null -w "%{http_code}" "$BASE_URL/api/wecom/callback?msg_signature=xxx&timestamp=1&nonce=1&echostr=xxx")
if [ "$wecom_get" != "200" ] && [ "$wecom_get" != "400" ]; then
echo "WARN wecom GET: got $wecom_get (expected 200 or 400)"
fi
echo "OK (status $wecom_get)"
echo "=== All checks passed ==="