| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- """A2 smoke test v2: real endpoints from saz capture.
- Tests request_sms against the REAL user-api.996hezi.com endpoint with a
- fake phone. Expected good outcomes:
- - 101000 (captcha required) → endpoint + protocol CORRECT
- - 40001 (phone format) → endpoint alive, validating
- - anything except 404 / SSL error → progress
- Note: user-api.996hezi.com 的证书链在裸 httpx 下验不过 (缺中间证书),
- smoke 模式关 verify; 真跑 A2 时 Box996Login 自带 httpx 客户端同样要处理。
- """
- import asyncio
- import ssl
- import sys
- from pathlib import Path
- _HERE = Path(__file__).resolve().parent
- sys.path.insert(0, str(_HERE.parent / "src"))
- from cq2_sdk.env_loader import load_env
- load_env(_HERE.parent / ".env")
- import httpx
- from cq2_sdk.login import Box996Login, CaptchaRequiredError, ManualGeetestSolver
- from cq2_sdk.login.box_996 import Box996Error
- DEVICE_ID = "00:15:5d:0a:04:00"
- FAKE_PHONE = "13800138000"
- async def main() -> int:
- box = Box996Login(geetest=ManualGeetestSolver(), device_id=DEVICE_ID)
- # 关证书验证 (只 smoke 用; 证书链问题见文件头注释)
- box._client = httpx.AsyncClient(
- timeout=15, verify=False,
- headers={"User-Agent": "996Box/5.1.1.9007"},
- )
- print(f"[smoke] request_sms({FAKE_PHONE!r}) against REAL endpoint")
- print(f" POST user-api.996hezi.com/v1/UserInfo/get_phone_code")
- print()
- try:
- resp = await box.request_sms(FAKE_PHONE)
- print(f"[UNEXPECTED-OK] 200: {resp!r}")
- return 0
- except CaptchaRequiredError as e:
- print(f"[BEST-CASE] 101000 captcha required: {e}")
- print(" → endpoint + protocol CORRECT (server processed request)")
- print(" → real run prompts geetest here, then resends with _captcha_")
- return 0
- except Box996Error as e:
- print(f"[GOOD] server responded code={e.code}: {e.msg[:80]}")
- print(f" endpoint={e.endpoint}")
- print(" → endpoint alive, request shape accepted")
- return 0
- except Exception as e:
- print(f"[ERROR] {type(e).__name__}: {str(e)[:150]}")
- return 1
- if __name__ == "__main__":
- sys.exit(asyncio.run(main()))
|