chore: L2 验证脚本
This commit is contained in:
46
scripts/verify-l2.sh
Normal file
46
scripts/verify-l2.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# L2 端到端验证脚本
|
||||
set -euo pipefail
|
||||
TOKEN="98c118601275607be1f244f0f9c40c838b7f0d74d0ce23c04eeda00db99eb95e"
|
||||
BASE="http://127.0.0.1:8180/api/v1"
|
||||
H=(-H "Authorization: Bearer $TOKEN")
|
||||
PASS=0 FAIL=0
|
||||
|
||||
ok() { echo " ✅ $1"; PASS=$((PASS+1)); }
|
||||
bad() { echo " ❌ $1"; FAIL=$((FAIL+1)); }
|
||||
|
||||
echo "=== L2 端到端验证 ==="
|
||||
|
||||
# ── 1. PUT /sessions/:id/permission
|
||||
SID=$(sqlite3 /opt/agentmail/data/agentmail.db "SELECT session_id FROM sessions ORDER BY updated_at DESC LIMIT 1;")
|
||||
echo "1. PUT /sessions/:id/permission ($SID)"
|
||||
|
||||
# 改 plan
|
||||
R=$(curl -s -X PUT "$BASE/sessions/$SID/permission" -H 'Content-Type: application/json' "${H[@]}" -d '{"permission_mode":"plan"}')
|
||||
if echo "$R" | grep -q '"permission_mode":"plan"'; then ok "plan 写入成功"; else bad "plan 写入失败: $R"; fi
|
||||
|
||||
# 改 full
|
||||
R=$(curl -s -X PUT "$BASE/sessions/$SID/permission" -H 'Content-Type: application/json' "${H[@]}" -d '{"permission_mode":"full"}')
|
||||
if echo "$R" | grep -q '"permission_mode":"full"'; then ok "full 写入成功"; else bad "full 写入失败: $R"; fi
|
||||
|
||||
# 脏值 → 回落到 workspace
|
||||
R=$(curl -s -X PUT "$BASE/sessions/$SID/permission" -H 'Content-Type: application/json' "${H[@]}" -d '{"permission_mode":"bogus"}')
|
||||
if echo "$R" | grep -q '"permission_mode":"workspace"'; then ok "脏值回落到 workspace"; else bad "脏值未回落: $R"; fi
|
||||
|
||||
# 复原
|
||||
curl -s -X PUT "$BASE/sessions/$SID/permission" -H 'Content-Type: application/json' "${H[@]}" -d '{"permission_mode":"workspace"}' > /dev/null
|
||||
|
||||
# ── 2. calendar_events.permission_mode 列
|
||||
echo "2. calendar_events.permission_mode 列"
|
||||
COL=$(sqlite3 /opt/agentmail/data/agentmail.db "PRAGMA table_info(calendar_events);" | grep permission_mode || true)
|
||||
if [ -n "$COL" ]; then ok "列存在: $COL"; else bad "列不存在"; fi
|
||||
|
||||
# ── 3. 建会话检查 schema 两列
|
||||
echo "3. sessions permission_mode/enforcement 列"
|
||||
PM=$(sqlite3 /opt/agentmail/data/agentmail.db "PRAGMA table_info(sessions);" | grep permission_mode || true)
|
||||
PE=$(sqlite3 /opt/agentmail/data/agentmail.db "PRAGMA table_info(sessions);" | grep permission_enforcement || true)
|
||||
if [ -n "$PM" ]; then ok "permission_mode 列存在"; else bad "permission_mode 列缺失"; fi
|
||||
if [ -n "$PE" ]; then ok "permission_enforcement 列存在"; else bad "permission_enforcement 列缺失"; fi
|
||||
|
||||
echo ""
|
||||
echo "=== 结果: $PASS 通过, $FAIL 失败 ==="
|
||||
Reference in New Issue
Block a user