Files

46 lines
2.8 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""CHG-061 鉴权矩阵实测:no-token / admin-token / ai-token × saveOrUpdate / aiBatchAdd / uploadBind"""
import io, sys, json, requests
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
B = 'http://localhost:8086'
AI = open('.claude/ai_token.txt').read().strip()
ADMIN = open('tmp/pw_token_8086.txt').read().strip()
def call(name, method, path, token, **kw):
h = {'Authorization': token} if token else {}
r = requests.request(method, B + path, headers=h, timeout=30, **kw)
try:
d = r.json()
msg = d.get('message', '')
if isinstance(msg, str):
try: msg = msg.encode('latin-1').decode('utf-8')
except Exception: pass
print(f'{name:28s} → HTTP {r.status_code} code={d.get("code")} msg={str(msg)[:40]} data={json.dumps(d.get("data"), ensure_ascii=False)[:60]}')
return d
except Exception:
print(f'{name:28s} → HTTP {r.status_code} 非JSON: {r.text[:80]}')
return None
expand_payload = {'storyId': 9130, 'workloadIndex': '5.1', 'numberUnits': 3, 'unitBusinessComplexity': '2.2',
'technicalComplexityCoefficient': '1.4', 'aiEfficiencyCoefficient': '0.55', 'requirementStatus': 'inProgress'}
task_payload = {'storyId': 9130, 'tasks': [{'name': '鉴权矩阵验证(可删)', 'type': 'devel', 'assignedTo': 'luoyong',
'aiEvaluationTime': 0.1, 'planStartDate': '2026-08-06', 'deadline': '2026-08-06'}]}
open('tmp/_auth_probe.md', 'w').write('# 鉴权矩阵验证\n')
print('== 无 token ==')
call('saveOrUpdate', 'POST', '/zentao/zt-story-expand/saveOrUpdate', None, json=expand_payload)
call('aiBatchAdd', 'POST', '/zentao/zt-task/aiBatchAdd', None, json=task_payload)
call('uploadBind', 'POST', '/zentao/common/uploadBind', None,
data={'objectType': 'testOther', 'objectId': '9130'}, files={'file': ('p.md', open('tmp/_auth_probe.md','rb'))})
print('== admin token(非ai)==')
call('saveOrUpdate', 'POST', '/zentao/zt-story-expand/saveOrUpdate', ADMIN, json=expand_payload)
call('aiBatchAdd', 'POST', '/zentao/zt-task/aiBatchAdd', ADMIN, json=task_payload)
call('uploadBind', 'POST', '/zentao/common/uploadBind', ADMIN,
data={'objectType': 'testOther', 'objectId': '9130', 'title': '鉴权矩阵-admin(可删)'}, files={'file': ('p.md', open('tmp/_auth_probe.md','rb'))})
print('== ai token ==')
call('saveOrUpdate', 'POST', '/zentao/zt-story-expand/saveOrUpdate', AI, json=expand_payload)
d = call('aiBatchAdd', 'POST', '/zentao/zt-task/aiBatchAdd', AI, json=task_payload)
d2 = call('uploadBind', 'POST', '/zentao/common/uploadBind', AI,
data={'objectType': 'testOther', 'objectId': '9130', 'title': '鉴权矩阵-ai(可删)'}, files={'file': ('p.md', open('tmp/_auth_probe.md','rb'))})
if d and d.get('data'): print('AI_TASK_ID=', d['data'].get('taskIds'))