[split-upload 4/6] f2fd4fa backup via proxy
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import redis
|
||||
import json
|
||||
import secrets
|
||||
import sys
|
||||
|
||||
REDIS_PWD = "WKzl7jgKTkeWxFWGIBXfzokm59Gvfr76"
|
||||
|
||||
try:
|
||||
r = redis.Redis(host="redis", port=6379, password=REDIS_PWD, db=0)
|
||||
print("Redis connect OK")
|
||||
|
||||
# Ping
|
||||
print(f"PING: {r.ping()}")
|
||||
|
||||
# Test write
|
||||
r.setex("test:debug_token", 60, "test_value")
|
||||
print(f"GET: {r.get('test:debug_token')}")
|
||||
|
||||
# 写 token
|
||||
token = secrets.token_urlsafe(32)
|
||||
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",
|
||||
}
|
||||
r.setex(f"user:token:{token}", 8 * 3600, json.dumps(user_info, ensure_ascii=False))
|
||||
print(f"Token written: {token}")
|
||||
|
||||
# 验证
|
||||
val = r.get(f"user:token:{token}")
|
||||
print(f"Stored: {val[:80] if val else 'None'}")
|
||||
|
||||
# 输出token到文件
|
||||
with open("/tmp/test_token.txt", "w") as f:
|
||||
f.write(token)
|
||||
print(f"Token saved to /tmp/test_token.txt")
|
||||
|
||||
except Exception as e:
|
||||
print(f"FAIL: {e}", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
Reference in New Issue
Block a user