Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/test_key_provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,9 @@ def test_blank_order_id_returns_400(self, hs):
_post_subscription(client, "xBridge Founder", "buyer@example.com")
resp = client.post("/keys/mine", json={"email": "buyer@example.com", "order_id": ""})
assert resp.status_code == 400

def test_non_ascii_order_id_returns_404_not_500(self, hs):
client = TestClient(hs.app)
_post_subscription(client, "xBridge Founder", "buyer@example.com")
resp = client.post("/keys/mine", json={"email": "buyer@example.com", "order_id": "ord-é123"})
assert resp.status_code == 404
4 changes: 3 additions & 1 deletion xbridge_mcp/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,9 @@ async def keys_mine(request: Request):
return not_found

stored_order_id = str(entry.get("order_id") or "")
if not stored_order_id or not hmac.compare_digest(submitted_order_id, stored_order_id):
if not stored_order_id or not hmac.compare_digest(
submitted_order_id.encode("utf-8"), stored_order_id.encode("utf-8")
):
return not_found

return JSONResponse({"key": entry["key"], "tier": entry["tier"], "email": email})
Expand Down