Add end-to-end smoke script covering LobeChat + Gateway + admin-lock + identity-aware manifest
E2E CI / Check Duplicate Run (push) Failing after 2s
Test CI / Check Duplicate Run (push) Failing after 2s
🔄 Branch Synchronization / sync-branches (push) Failing after 3s
E2E CI / Test Web App (push) Has been skipped
Test CI / Test App (shard 2/3) (push) Has been skipped
Test CI / Test App (shard 1/3) (push) Has been skipped
Test CI / Test Packages (push) Has been skipped
Test CI / Test App (shard 3/3) (push) Has been skipped
Test CI / Test Database (push) Has been skipped
Test CI / Test Desktop App (push) Has been skipped
Test CI / Merge and Upload App Coverage (push) Has been skipped
Lighthouse Badger / LobeChat | Chat (push) Has been cancelled
Lighthouse Badger / LobeChat | Market (push) Has been cancelled
Issue Close Require / issue-check-inactive (push) Failing after 2s
Issue Close Require / issue-close-require (push) Failing after 3s
Daily i18n Update / update-i18n (push) Failing after 2m35s
Lock Stale Issues / lock-closed-issues (push) Successful in 47s
Claude Translate Non-English Comments / translate-comments (push) Failing after 1m2s
Auto-close duplicate issues / auto-close-duplicates (push) Successful in 3m18s
Claude Auto Testing Coverage / add-tests (push) Failing after 38s
Upstream Sync / Sync latest commits from upstream repo (push) Has been skipped
Claude Auto E2E Testing / add-e2e-tests (push) Failing after 41s

This commit is contained in:
xiaohei
2026-04-21 21:12:39 +08:00
parent 73821abe00
commit dc2abbd6e9
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
# End-to-end smoke test across LobeChat + Enterprise Gateway.
# Exit 0 if all checks pass, non-zero otherwise.
set -u
LC=${LC:-http://localhost:3010}
GW=${GW:-http://localhost:3001}
pass=0; fail=0
declare -a results
check() {
local name="$1" ok="$2" detail="$3"
if [ "$ok" = "1" ]; then pass=$((pass+1)); results+=("PASS $name"); echo "PASS $name"
else fail=$((fail+1)); results+=("FAIL $name -- $detail"); echo "FAIL $name -- $detail"; fi
}
# 1. Health probes
curl -sf "$LC/" -o /dev/null -w "" || true
code=$(curl -s -o /dev/null -w "%{http_code}" "$GW/health")
[ "$code" = "200" ] && check "gateway /health 200" 1 "" || check "gateway /health" 0 "got $code"
# 2. Sign-in as admin + capture session
curl -sL -X POST "$LC/api/auth/sign-in/email" \
-H "Content-Type: application/json" -c /tmp/e2e-admin.txt \
-d '{"email":"admin@eg.local","password":"Admin@12345"}' -o /tmp/e2e-signin.json -w "" >/dev/null
token=$(python3 -c "import json;print(json.load(open('/tmp/e2e-signin.json')).get('token',''))" 2>/dev/null)
[ -n "$token" ] && check "lobechat admin sign-in" 1 "" || check "lobechat admin sign-in" 0 "no token"
# 3. enterprise/me returns is_admin=true
me=$(curl -sL -b /tmp/e2e-admin.txt "$LC/webapi/enterprise/me")
echo "$me" | grep -q '"is_admin":true' && check "enterprise/me admin is_admin=true" 1 "" || check "enterprise/me admin" 0 "$me"
# 4. tRPC plugin list contains enterprise-gateway custom plugin
plist=$(curl -sL -b /tmp/e2e-admin.txt "$LC/trpc/lambda/plugin.getPlugins?input=%7B%22json%22%3Anull%7D")
echo "$plist" | grep -q 'enterprise-gateway' && check "lobechat plugin.getPlugins has enterprise-gateway" 1 "" || check "plugin.getPlugins" 0 "$plist"
# 5. tRPC provider runtime state contains azure
prov=$(curl -sL -b /tmp/e2e-admin.txt "$LC/trpc/lambda/aiProvider.getAiProviderRuntimeState?input=%7B%22json%22%3A%7B%7D%7D")
echo "$prov" | grep -qi 'azure' && check "lobechat aiProvider.getAiProviderRuntimeState has azure" 1 "" || check "provider runtime" 0 "${prov:0:200}"
# 6. Non-admin signup + check 403 on provider mutation
curl -sL -X POST "$LC/api/auth/sign-up/email" \
-H "Content-Type: application/json" -c /tmp/e2e-normal.txt \
-d '{"email":"smoke-'$$'@eg.local","password":"Admin@12345","name":"Smoke"}' -o /tmp/e2e-normal.json -w "" >/dev/null || true
code=$(curl -sL -o /tmp/e2e-mut.json -w "%{http_code}" -X POST -b /tmp/e2e-normal.txt \
"$LC/trpc/lambda/aiProvider.createAiProvider" \
-H "Content-Type: application/json" \
-d '{"json":{"id":"smoke'$$'","name":"Smoke","enabled":true,"source":"custom"}}')
[ "$code" = "403" ] && check "non-admin aiProvider mutation -> 403" 1 "" || check "non-admin mutation block" 0 "got $code"
# 7. Gateway capabilities (direct) for admin
cap=$(curl -sL -H "X-Dev-User: sa" "$GW/api/capabilities")
tools=$(echo "$cap" | python3 -c "import json,sys;print(len(json.load(sys.stdin).get('tools',[])))" 2>/dev/null || echo 0)
[ "$tools" -ge 10 ] && check "gateway capabilities sa >=10 tools ($tools)" 1 "" || check "capabilities sa tools" 0 "got $tools"
# 8. lobechat plugin manifest (called by LobeChat) is identity-aware
mfs=$(curl -sL -H "X-Dev-User: sales1" "$GW/api/lobechat/manifest")
count_sales=$(echo "$mfs" | python3 -c "import json,sys;print(len(json.load(sys.stdin).get('api',[])))" 2>/dev/null || echo 0)
mfc=$(curl -sL -H "X-Dev-User: cust1" "$GW/api/lobechat/manifest")
count_cust=$(echo "$mfc" | python3 -c "import json,sys;print(len(json.load(sys.stdin).get('api',[])))" 2>/dev/null || echo 0)
[ "$count_sales" -gt "$count_cust" ] && check "manifest sales1 ($count_sales) > cust1 ($count_cust)" 1 "" || check "manifest shrink" 0 "sales=$count_sales cust=$count_cust"
echo
echo "=========================================="
echo "Summary: pass=$pass fail=$fail"
echo "=========================================="
for r in "${results[@]}"; do echo " $r"; done
[ "$fail" = "0" ]