test(coupon-proxy): 修正已过时的 401 鉴权断言
coupon/step MVP 阶段已去鉴权(见「待办与技术债.md」已解决),但 test_coupon_step_requires_auth 仍断言"无 token → 401",baseline 实际走到上游 拿 502,这条用例长期红灯。改为 mock httpx 验证不带 token 也能正常透传,与新加的 compare 端点 no-auth 测试一致。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -44,10 +44,21 @@ def access_token(client) -> str:
|
|||||||
return r.json()["access_token"]
|
return r.json()["access_token"]
|
||||||
|
|
||||||
|
|
||||||
def test_coupon_step_requires_auth(client) -> None:
|
def test_coupon_step_no_auth_required(client) -> None:
|
||||||
"""无 token → 401(get_current_user 拦下)。"""
|
"""MVP 不鉴权:不带 token 也能转发(已去掉 CurrentUser,device_id 透传)。
|
||||||
r = client.post("/api/v1/coupon/step", json=_stub_request_body())
|
|
||||||
assert r.status_code == 401
|
历史:本测试原断言"无 token → 401",但 coupon/step 已去鉴权(见 docs/待办与
|
||||||
|
技术债.md「已解决」),401 断言已过时,改为验证不带 token 也能正常透传。
|
||||||
|
"""
|
||||||
|
async def fake_post(self, url, json=None, **kw):
|
||||||
|
mock_resp = MagicMock()
|
||||||
|
mock_resp.status_code = 200
|
||||||
|
mock_resp.json = lambda: {"success": True}
|
||||||
|
return mock_resp
|
||||||
|
|
||||||
|
with patch.object(httpx.AsyncClient, "post", fake_post):
|
||||||
|
r = client.post("/api/v1/coupon/step", json=_stub_request_body())
|
||||||
|
assert r.status_code == 200, r.text
|
||||||
|
|
||||||
|
|
||||||
def test_coupon_step_passes_body_through(client, access_token) -> None:
|
def test_coupon_step_passes_body_through(client, access_token) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user