fix(backend): redact retryable MAX storage failures
CI / ruff · pytest (pull_request) Successful in 2m4s
CI / ruff · pytest (pull_request) Successful in 2m4s
Refs #82
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
"""MAX endpoints authenticate before reading bindings or accepting events."""
|
||||
|
||||
import sys
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import AsyncMock
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
from sqlalchemy.exc import OperationalError
|
||||
|
||||
from app.config import get_settings
|
||||
from app.core import clock
|
||||
@@ -90,3 +94,10 @@ async def test_webhook_secret_checked_before_body_or_adapter(client):
|
||||
assert (await client.post(HOOK, headers=headers, content="not-json")).status_code == 400
|
||||
assert (await client.post(HOOK, headers=headers, json=[])).status_code == 422
|
||||
assert (await client.post(HOOK, headers=headers, content=" " * 65537)).status_code == 413
|
||||
|
||||
|
||||
async def test_webhook_storage_failure_is_retryable_without_identity_details(client, monkeypatch):
|
||||
handler = AsyncMock(side_effect=OperationalError("private SQL", {"token": TOKEN}, Exception("private")))
|
||||
monkeypatch.setitem(sys.modules, "app.channels.max_bot", SimpleNamespace(handle_update=handler))
|
||||
response = await client.post(HOOK, headers={"X-Max-Bot-Api-Secret": SECRET}, json={})
|
||||
assert response.status_code == 503 and TOKEN not in response.text and "private" not in response.text
|
||||
|
||||
Reference in New Issue
Block a user