7864ab404b
**目录结构**: - 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 行
61 lines
2.2 KiB
Python
61 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify WeCom contact sync works after IP whitelist configuration."""
|
|
import httpx
|
|
import json
|
|
|
|
CORP_ID = "wwa8c87970b2011f41"
|
|
CONTACT_SECRET = "BM6iosc3gKnPqkEXmsQN3ErJUpfO-whfMUN646eezB8"
|
|
|
|
# Step 1: Get contact access token
|
|
print("=" * 60)
|
|
print("Step 1: Get contact access token")
|
|
resp = httpx.get(f"https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={CORP_ID}&corpsecret={CONTACT_SECRET}", timeout=10)
|
|
token_data = resp.json()
|
|
print(f" errcode: {token_data.get('errcode')}")
|
|
print(f" errmsg: {token_data.get('errmsg')}")
|
|
|
|
if 'access_token' not in token_data:
|
|
print(" FAILED: No access token returned")
|
|
exit(1)
|
|
|
|
token = token_data['access_token']
|
|
print(f" access_token: {token[:30]}...")
|
|
|
|
# Step 2: Get department list
|
|
print("\n" + "=" * 60)
|
|
print("Step 2: Get department list")
|
|
resp2 = httpx.get(f"https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token={token}", timeout=10)
|
|
dept_data = resp2.json()
|
|
print(f" errcode: {dept_data.get('errcode')}")
|
|
print(f" errmsg: {dept_data.get('errmsg')}")
|
|
departments = dept_data.get('department', [])
|
|
print(f" department count: {len(departments)}")
|
|
if departments:
|
|
print(f" first 5 departments:")
|
|
for d in departments[:5]:
|
|
print(f" - id={d.get('id')}, name={d.get('name')}, parentid={d.get('parentid')}")
|
|
|
|
# Step 3: Get members of root department (id=1)
|
|
print("\n" + "=" * 60)
|
|
print("Step 3: Get members of root department (id=1)")
|
|
resp3 = httpx.get(f"https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token={token}&department_id=1&fetch_child=1", timeout=15)
|
|
user_data = resp3.json()
|
|
print(f" errcode: {user_data.get('errcode')}")
|
|
print(f" errmsg: {user_data.get('errmsg')}")
|
|
users = user_data.get('userlist', [])
|
|
print(f" user count: {len(users)}")
|
|
if users:
|
|
print(f" first 3 users:")
|
|
for u in users[:3]:
|
|
print(f" - userid={u.get('userid')}, name={u.get('name')}, department={u.get('department')}")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("SUMMARY:")
|
|
print(f" Token: OK")
|
|
print(f" Departments: {len(departments)}")
|
|
print(f" Users: {len(users)}")
|
|
if dept_data.get('errcode') == 0 and len(departments) > 0:
|
|
print(" RESULT: SUCCESS - Contact sync is working!")
|
|
else:
|
|
print(" RESULT: STILL FAILING")
|