feat: add web auth wx-qr create and status endpoints

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-09-18 13:53:40 +08:00
1 parent 9d4a11339b
commit 38b11cce35
2 files changed
+76

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
"""web wx-qr create/status API。"""
from unittest.mock import patch
from fastapi.testclient import TestClient
from app.main import app
from app.services import wx_qr_session
client = TestClient(app)
def setup_function():
wx_qr_session._memory_clear_for_tests()
def test_wx_qr_create_and_poll_pending():
with patch("app.services.wx_qr_session._redis", return_value=None), patch(
"app.api.public.get_unlimited_wxacode",
return_value=b"\x89PNG\r\n\x1a\n",
):
r = client.post("/api/web/auth/wx-qr/create")
assert r.status_code == 200
body = r.json()
assert body.get("code") == 200
data = body["data"]
sid = data["sessionId"]
assert data["qrImageBase64"].startswith("data:image/")
st = client.get("/api/web/auth/wx-qr/status", params={"sessionId": sid})
assert st.status_code == 200
assert st.json()["data"]["status"] == "pending"