#!/usr/bin/env bash # 本地 API 功能冒烟测试(不打包) set -euo pipefail BASE="${API_BASE:-http://127.0.0.1:3000/api/v1}" PASS="${TEST_PASS:-Admin@123456}" USER="${TEST_USER:-admin}" echo "== health ==" curl -sf "$BASE/health/live" | head -c 200; echo echo "== login ==" LOGIN=$(curl -sf -X POST "$BASE/auth/login" -H 'Content-Type: application/json' -d "{\"username\":\"$USER\",\"password\":\"$PASS\",\"agreeTerms\":true}") TOKEN=$(echo "$LOGIN" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('data',{}).get('accessToken','') or d.get('accessToken',''))") if [ -z "$TOKEN" ]; then echo "LOGIN FAIL: $LOGIN"; exit 1; fi echo "token ok (${#TOKEN} chars)" AUTH="Authorization: Bearer $TOKEN" echo "== app-release ==" curl -sf "$BASE/system/app-release" -H "$AUTH" | python3 -m json.tool | head -15 echo "== im status ==" curl -sf "$BASE/im/status" -H "$AUTH" | python3 -m json.tool | head -10 echo "== voice transcribe (expect 400 bad fileId) ==" CODE=$(curl -s -o /tmp/asr.json -w '%{http_code}' -X POST "$BASE/im/voice/transcribe" -H "$AUTH" -H 'Content-Type: application/json' -d '{"fileId":""}') echo "HTTP $CODE"; cat /tmp/asr.json; echo echo "== attendance punch-status (no coords) ==" curl -sf "$BASE/attendance/punch-status?mode=OFFICE" -H "$AUTH" | python3 -m json.tool | head -12 echo "ALL SMOKE CHECKS DONE"