forked from mtusi2026/mtusi2026lab4
lab4: S3, MinIO, reconciler, трек 2, README
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
============================= test session starts ==============================
|
||||
platform darwin -- Python 3.13.2, pytest-8.3.4, pluggy-1.6.0 -- /Users/kirill/Downloads/drone_simulation_project/.venv/bin/python
|
||||
cachedir: .pytest_cache
|
||||
rootdir: /Users/kirill/Desktop/esp/temka/mtusi2026lab4
|
||||
plugins: platformdirs-4.12.2, anyio-3.6.2
|
||||
collecting ... collected 5 items
|
||||
|
||||
tests/test_attachments.py::test_file_too_large PASSED [ 20%]
|
||||
tests/test_attachments.py::test_corrupted_image PASSED [ 40%]
|
||||
tests/test_attachments.py::test_mime_spoofing PASSED [ 60%]
|
||||
tests/test_attachments.py::test_foreign_attachment_access PASSED [ 80%]
|
||||
tests/test_attachments.py::test_attachment_from_other_chat FAILED [100%]
|
||||
|
||||
=================================== FAILURES ===================================
|
||||
_______________________ test_attachment_from_other_chat ________________________
|
||||
|
||||
def test_attachment_from_other_chat():
|
||||
"""Файл из чужого чата нельзя прикрепить к своему сообщению."""
|
||||
# Пользователь 1 создает чат и файл
|
||||
token1 = register_and_login("test_chat_1")
|
||||
chat_id1 = create_chat(token1)
|
||||
content = make_png(10, 10)
|
||||
resp_upload = upload_file(token1, chat_id1, content)
|
||||
att_id = resp_upload.json()["id"]
|
||||
|
||||
# Пользователь 2 создает свой чат
|
||||
token2 = register_and_login("test_chat_2")
|
||||
chat_id2 = create_chat(token2)
|
||||
|
||||
# Пользователь 2 пытается отправить сообщение в СВОЙ чат, прикрепив ЧУЖОЙ файл
|
||||
headers2 = {"Authorization": f"Bearer {token2}"}
|
||||
resp_msg = requests.post(
|
||||
f"{BASE_URL}/api/v1/chats/{chat_id2}/messages",
|
||||
headers={**headers2, "Idempotency-Key": str(uuid.uuid4())},
|
||||
json={"text": "взлом", "attachment_ids": [att_id]}
|
||||
)
|
||||
# В идеале должно быть 400 (нельзя прикрепить чужое), но зависит от реализации
|
||||
> assert resp_msg.status_code in (400, 403, 404), f"Ожидался отказ, получен {resp_msg.status_code}"
|
||||
E AssertionError: Ожидался отказ, получен 201
|
||||
E assert 201 in (400, 403, 404)
|
||||
E + where 201 = <Response [201]>.status_code
|
||||
|
||||
tests/test_attachments.py:108: AssertionError
|
||||
=========================== short test summary info ============================
|
||||
FAILED tests/test_attachments.py::test_attachment_from_other_chat - Assertion...
|
||||
========================= 1 failed, 4 passed in 4.48s ==========================
|
||||
Reference in New Issue
Block a user