Forward the lab 5 foundation while preserving lab 6 telemetry
Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.
Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
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