forked from mtusi2026/mtusi2026lab2
Forward the lab 4 foundation and migrate the lab 5 pipeline to SQLAlchemy
This commit is contained in:
@@ -9,7 +9,7 @@ import pytest
|
||||
from httpx import AsyncClient, Response
|
||||
from PIL import Image
|
||||
|
||||
from conftest import actor, make_chat, register, resolve, scalar
|
||||
from conftest import actor, make_chat, register, resolve, running_app, scalar
|
||||
from fakes import MemoryObjectStorage
|
||||
from messenger.attachments.application.ports import ObjectStorage
|
||||
from pictures import GIF, JPEG, SAMPLE, WEBP, png
|
||||
@@ -140,6 +140,18 @@ async def test_access_is_checked_before_content(client: AsyncClient) -> None:
|
||||
assert anonymous.headers["www-authenticate"] == 'Bearer realm="messenger"'
|
||||
|
||||
|
||||
async def test_token_is_checked_before_the_declared_size() -> None:
|
||||
async with running_app(max_upload_bytes=4096) as http:
|
||||
alice, _, _, chat = await trio(http)
|
||||
oversized = png(16, 16, size=8192)
|
||||
anonymous = await http.post(
|
||||
f"/api/v1/chats/{chat['id']}/attachments?filename=a.png", content=oversized, headers=PNG
|
||||
)
|
||||
assert anonymous.status_code == 401
|
||||
assert anonymous.headers["www-authenticate"] == 'Bearer realm="messenger"'
|
||||
assert (await upload(http, alice, chat, oversized)).status_code == 413
|
||||
|
||||
|
||||
async def test_exact_limit_is_accepted(client: AsyncClient) -> None:
|
||||
alice, _, _, chat = await trio(client)
|
||||
response = await upload(client, alice, chat, png(16, 16, size=LIMIT))
|
||||
|
||||
Reference in New Issue
Block a user