| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #!/usr/bin/env python3
- """Corrected S4 + a few remaining smoke APIs after path fix."""
- import json
- import urllib.request
- from gmssl import sm2
- BASE = "http://127.0.0.1:5005"
- TENANT = 797403760988229
- PK = "84C7466D950E120E5ECE5DD85D0C90EAA85081A3A2BD7C57AE6DC822EFCCBD66620C67B0103FC8DD280E36C3B282977B722AAEC3C56518EDCEBAFB72C5A05312"
- def http(method, path, body=None, token=None):
- headers = {"Content-Type": "application/json", "Accept": "application/json"}
- if token:
- headers["Authorization"] = f"Bearer {token}"
- data = None if body is None else json.dumps(body).encode()
- req = urllib.request.Request(BASE + path, data=data, headers=headers, method=method)
- try:
- with urllib.request.urlopen(req, timeout=120) as r:
- raw = r.read().decode()
- return r.status, json.loads(raw) if raw else {}
- except Exception as e:
- if hasattr(e, "read"):
- raw = e.read().decode("utf-8", "replace")
- try:
- return getattr(e, "code", 0), json.loads(raw)
- except Exception:
- return getattr(e, "code", 0), {"raw": raw[:400]}
- return 0, {"error": str(e)}
- crypt = sm2.CryptSM2(public_key=PK, private_key=None, mode=1)
- pwd = crypt.encrypt(b"1234567890dop").hex()
- st, body = http("POST", "/api/sysAuth/login", {"account": "AIDOPDemo", "password": pwd, "tenantId": str(TENANT)})
- token = (body.get("result") or {}).get("accessToken")
- assert token, body
- apis = [
- ("GET", "/api/ProcurementExecution/supplier-shipment/list?page=1&pageSize=5"),
- ("GET", "/api/ProcurementExecution/supplier-delivery/list?page=1&pageSize=5"),
- ("GET", "/api/ProcurementExecution/supplier-shortage-kanban/list?page=1&pageSize=5"),
- ("GET", "/api/ProcurementExecution/iqc-return/list?page=1&pageSize=5"),
- ("GET", "/api/ProcurementExecution/purchase-return/list?page=1&pageSize=5"),
- ("GET", "/api/WorkOrder/dispatch/list?page=1&pageSize=5"),
- ("GET", "/api/Production/daily-plan/list?page=1&pageSize=5"),
- ("GET", "/api/Supply/work-order-material-readiness/list?page=1&pageSize=5&keyword=M000000005"),
- ]
- out = []
- for method, path in apis:
- st, b = http(method, path, token=token)
- res = b.get("result", b) if isinstance(b, dict) else b
- brief = {}
- if isinstance(res, dict):
- for k in ("total", "list", "message", "page"):
- if k in res:
- brief[k] = len(res[k]) if k == "list" and isinstance(res[k], list) else res[k]
- if not brief:
- brief = {"keys": list(res.keys())[:8], "code": b.get("code"), "msg": str(b.get("message") or "")[:160]}
- out.append(
- {
- "api": f"{method} {path.split('?')[0]}",
- "http": st,
- "ok": st == 200 and (not isinstance(b, dict) or b.get("code", 200) in (200, None)),
- "brief": brief,
- "err": (b.get("message") if isinstance(b, dict) else None) or (b.get("error") if isinstance(b, dict) else None),
- }
- )
- path = r"d:\Projects\Ai-DOP\SourceCode\ZZYDOP\doc\_verify_s1_s4_continue_s4fix_result.json"
- with open(path, "w", encoding="utf-8") as f:
- json.dump(out, f, ensure_ascii=False, indent=2, default=str)
- print(json.dumps(out, ensure_ascii=False, indent=2, default=str))
|