feat(scripts): 收纳运维/部署/修复/调试脚本到 scripts/ 目录

**目录结构**:
- scripts/                 顶层运维/工具脚本(20 个)
- scripts/deploy/          一键部署脚本(deploy_*.py / upload_*.py / redeploy.py 等 8 个)
- scripts/fix/             一次性修复脚本(fix_*.py / fix_*.cypher / fix_*.sql 等 9 个)
- scripts/debug/           调试脚本集合(check_*.py/sql、test_*.py、debug_*.py 等 42 个)

**ops-tools/jms_ops.py**:jumpserver-ops skill 默认路径修复
- 从 'jumpserver-automation-shareable' 改为 'jumpserver-ops'
- 同步更新注释(优先 JP_SKILL_DIR 环境变量)

**典型脚本用途**:
- scripts/deploy-v1.2.ps1 / -staging.ps1:一键部署 v1.2 到生产 / staging
- scripts/init_quick_rules.sql:quick_rules 表初始数据
- scripts/gen_admin_token.py:生成 admin JWT token(调试用)
- scripts/build-and-verify.sh:v1.1 实施验证脚本
- scripts/verify_*.sh / .py:API/quick_rules 验证
- scripts/fix/*.py:环境修复(compose、env_key、itsm_bridge 等)

合计 81 文件 + 3317 行 / - 1 行
This commit is contained in:
Simon
2026-08-03 18:48:02 +08:00
parent 44e77dcb0e
commit 7864ab404b
81 changed files with 3317 additions and 1 deletions
+97
View File
@@ -0,0 +1,97 @@
#!/bin/bash
# =============================================================================
# 验证 priority 修复 - 端到端测试 (v4 - 用 docker exec)
# =============================================================================
set -e
REDIS_PWD="WKzl7jgKTkeWxFWGIBXfzokm59Gvfr76"
TOKEN=$(openssl rand -hex 32)
# 1. 在 backend 容器内用 Python 写 token(容器已装 redis
USER_INFO='{"employee_id": "sxn", "username": "admin", "name": "宋献", "role": "admin", "department": "IT支持组", "login_source": "test", "login_method": "test_script", "last_active": "2026-07-28T02:00:00"}'
docker exec wecom_it_backend python3 - <<PYEOF
import redis
import json
r = redis.Redis(host="redis", port=6379, password="${REDIS_PWD}", db=0)
token = "${TOKEN}"
user_info = json.loads("""${USER_INFO}""")
r.setex(f"user:token:{token}", 8 * 3600, json.dumps(user_info, ensure_ascii=False))
print(f"Token written: {token[:20]}...")
print(f"Verified: {r.exists(f'user:token:{token}') == 1}")
PYEOF
# 2. 测试 API
echo ""
echo "===== Test 1: GET /admin/quick-rules?rule_type=routing_target ====="
RESP1=$(curl -s "http://localhost/api/admin/quick-rules?rule_type=routing_target&page=1&size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP1}" | python3 -m json.tool 2>&1 | head -80
# 3. 测试 API - category=行政
echo ""
echo "===== Test 2: GET /admin/quick-rules?rule_type=routing_target&category=行政 ====="
RESP2=$(curl -s --get "http://localhost/api/admin/quick-rules" \
--data-urlencode "rule_type=routing_target" \
--data-urlencode "category=行政" \
--data-urlencode "page=1" \
--data-urlencode "size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP2}" | python3 -m json.tool 2>&1 | head -50
# 4. 测试 API - category=人力资源
echo ""
echo "===== Test 3: GET /admin/quick-rules?rule_type=routing_target&category=人力资源 ====="
RESP3=$(curl -s --get "http://localhost/api/admin/quick-rules" \
--data-urlencode "rule_type=routing_target" \
--data-urlencode "category=人力资源" \
--data-urlencode "page=1" \
--data-urlencode "size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP3}" | python3 -m json.tool 2>&1 | head -50
# 5. 测试 API - category=IT服务
echo ""
echo "===== Test 4: GET /admin/quick-rules?rule_type=routing_target&category=IT服务 ====="
RESP4=$(curl -s --get "http://localhost/api/admin/quick-rules" \
--data-urlencode "rule_type=routing_target" \
--data-urlencode "category=IT服务" \
--data-urlencode "page=1" \
--data-urlencode "size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP4}" | python3 -m json.tool 2>&1 | head -50
# 6. 测试 API - category=行政-物业
echo ""
echo "===== Test 5: GET /admin/quick-rules?rule_type=routing_target&category=行政-物业 ====="
RESP5=$(curl -s --get "http://localhost/api/admin/quick-rules" \
--data-urlencode "rule_type=routing_target" \
--data-urlencode "category=行政-物业" \
--data-urlencode "page=1" \
--data-urlencode "size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP5}" | python3 -m json.tool 2>&1 | head -50
# 7. 测试 API - 不存在的分类
echo ""
echo "===== Test 6: GET /admin/quick-rules?rule_type=routing_target&category=不存在的分类 ====="
RESP6=$(curl -s --get "http://localhost/api/admin/quick-rules" \
--data-urlencode "rule_type=routing_target" \
--data-urlencode "category=不存在的分类" \
--data-urlencode "page=1" \
--data-urlencode "size=20" \
-H "Authorization: Bearer ${TOKEN}")
echo "${RESP6}" | python3 -m json.tool 2>&1 | head -20
# 8. cleanup
echo ""
echo "===== Cleanup ====="
docker exec wecom_it_backend python3 -c "
import redis
r = redis.Redis(host='redis', port=6379, password='${REDIS_PWD}', db=0)
print(r.delete(f'user:token:${TOKEN}'))
"
echo ""
echo "===== 验证完成 ====="