fix: 503 при сбое зависимостей, таймаут пула pg, сохранение NUL символа в сообщениях

This commit is contained in:
Ильяс
2026-10-23 22:21:19 +03:00
parent 9ddb2244bc
commit e1df60f069
5 changed files with 118 additions and 52 deletions
+10 -10
View File
@@ -394,16 +394,16 @@ async def test_unsupported_media_type_415(client: httpx.AsyncClient):
@pytest.mark.asyncio
async def test_nul_byte_in_strings_handled(client: httpx.AsyncClient):
"""Символ \\u0000 в строках не должен вызывать 500/503 и должен корректно обрабатываться."""
u = f"nul_user_{uuid.uuid4().hex[:6]}"
res = await client.post(
"/api/v1/users",
json={"username": u, "display_name": "Hello\u0000World", "password": "Password123456!"},
)
assert res.status_code == 201
data = res.json()
assert data["username"] == u
assert data["display_name"] == "HelloWorld"
usr = await register_and_login(client, f"nul_msg_{uuid.uuid4().hex[:4]}")
chat = (await client.post("/api/v1/chats", headers=usr["headers"], json={"title": "NulChat", "member_ids": [usr["user"]["id"]]})).json()
test_text = "left\u0000right"
msg_res = await client.post(f"/api/v1/chats/{chat['id']}/messages", headers=usr["headers"], json={"text": test_text})
assert msg_res.status_code == 201
assert msg_res.json()["text"] == test_text
list_res = await client.get(f"/api/v1/chats/{chat['id']}/messages", headers=usr["headers"])
assert list_res.status_code == 200
assert any(m["text"] == test_text for m in list_res.json()["items"])
@pytest.mark.asyncio