date: 2026-11-06T19:30:06Z commit: f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071 environment: {} $ .venv/bin/pytest -q student-tests/unit/test_png_upload.py student-tests/unit/test_authentication.py student-tests/unit/test_nul_inputs.py FF............FFFFFFFF.........FFFFFFFFFFFFFFFFF...FF [100%] =================================== FAILURES =================================== ________ test_broken_png_returns_415_before_any_storage_write[bad-zlib] ________ data = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x11IDATnot a zlib streamE\x00\xdcQ\x00\x00\x00\x00IEND\xaeB`\x82' @pytest.mark.parametrize( "data", [BROKEN_PNG, DUPLICATE_IHDR_PNG], ids=["bad-zlib", "duplicate-ihdr"] ) async def test_broken_png_returns_415_before_any_storage_write(data: bytes) -> None: uow = Mock(spec=AttachmentsUnitOfWork) uow.attachments = AsyncMock(spec=AttachmentRepository) uow.transaction.return_value = AsyncMock() uow.collect_new_events.return_value = [] storage = AsyncMock(spec=ObjectStorage) membership = AsyncMock(spec=ChatMembership) membership.is_member.return_value = True logger = NullLogger() publisher = RecordingPublisher() handler = UploadAttachmentHandler( uow, membership, PillowImageInspector(40_000_000, 1), storage, clock=Mock(spec=Clock, now=Mock(return_value=datetime(2026, 11, 6, tzinfo=UTC))), ids=Mock(spec=IdGenerator, new_id=Mock(side_effect=uuid4)), limit=10_485_760, slots=UploadSlots(1), logger=logger, ) bus = AttachmentsCommandBus({UploadAttachment: handler}, uow, publisher) container = SimpleNamespace(get=AsyncMock(return_value=bus)) owner, chat = uuid4(), uuid4() async def guard(scope: Scope) -> None: scope["state"].update(actor=owner, dishka_container=container) app = FastAPI() app.include_router(uploads_router) install(app, logger, ERROR_CODES, lambda _: "Bearer", "offline-test") transport = ASGITransport( app=RequestPipeline(app, logger, 10_485_760, 5, guard, "offline-test") ) async with AsyncClient(transport=transport, base_url="http://testserver") as http: > response = await http.post( f"/api/v1/chats/{chat}/attachments?filename=broken.png", headers={"Content-Type": "image/png", "X-Request-Id": "png-regression"}, content=data, ) student-tests/unit/test_png_upload.py:68: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.14/site-packages/httpx/_client.py:1859: in post return await self.request( .venv/lib/python3.14/site-packages/httpx/_client.py:1540: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( .venv/lib/python3.14/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( .venv/lib/python3.14/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_transports/asgi.py:170: in handle_async_request await self.app(scope, receive, send) src/messenger/shared/entrypoints/pipeline.py:162: in __call__ await self._app(scope, *pace.around(limited_receive, wrapped_send)) .venv/lib/python3.14/site-packages/fastapi/applications.py:1163: in __call__ await super().__call__(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/applications.py:96: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/middleware/errors.py:186: in __call__ raise exc .venv/lib/python3.14/site-packages/starlette/middleware/errors.py:164: in __call__ await self.app(scope, receive, _send) .venv/lib/python3.14/site-packages/starlette/middleware/exceptions.py:63: in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.14/site-packages/fastapi/middleware/asyncexitstack.py:18: in __call__ await self.app(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/routing.py:676: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:2734: in app await route.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1780: in handle await self.original_router.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:2789: in handle await included_router._handle_selected(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1800: in _handle_selected await original_route.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1279: in handle await app(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:158: in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.14/site-packages/fastapi/routing.py:144: in app response = await f(request) ^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/fastapi/routing.py:706: in app raw_response = await run_endpoint_function( .venv/lib/python3.14/site-packages/fastapi/routing.py:352: in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :3: in dishka_func_upload_attachment return await func_upload_attachment(*args, **kwargs, bus=await container.get(AttachmentsCommandBus, '')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/attachments/entrypoints/http.py:42: in upload_attachment attachment = await bus.execute( src/messenger/shared/application/messagebus.py:32: in execute return await handler(command) ^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = command = UploadAttachment(owner_id=UUID('f4e7391d-e379-4ff1-afc6-c5349e2c1a9b'), chat_id=UUID('cf94ebbf-fcdc-4eca-8a9f-4f0baf54b4b7'), filename='broken.png', content_type='image/png', body=) async def __call__(self, command: UploadAttachment) -> Attachment: if not await self._membership.is_member(command.chat_id, command.owner_id): raise ChatNotFound("чат не найден") filename = Filename(command.filename or "") declared = ImageKind.declared(command.content_type) async with self._slots: attachment = await self._write(command, filename, declared) now = self._clock.now() attachment.enqueue(now) job = Job(self._ids.new_id(), attachment.id, self._pipeline_version, 1, now) try: async with self._uow.transaction(): await self._uow.attachments.save(attachment) > await self._uow.jobs.add(job) E TypeError: 'Mock' object can't be awaited src/messenger/attachments/application/handlers.py:98: TypeError _____ test_broken_png_returns_415_before_any_storage_write[duplicate-ihdr] _____ data = b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\rIHDR\...\x00\x00\x00\xfd\xd4\x9as\x00\x00\x00\x0cIDATx\x9cc```\x00\x00\x00\x04\x00\x01\xf6\x178U\x00\x00\x00\x00IEND\xaeB`\x82' @pytest.mark.parametrize( "data", [BROKEN_PNG, DUPLICATE_IHDR_PNG], ids=["bad-zlib", "duplicate-ihdr"] ) async def test_broken_png_returns_415_before_any_storage_write(data: bytes) -> None: uow = Mock(spec=AttachmentsUnitOfWork) uow.attachments = AsyncMock(spec=AttachmentRepository) uow.transaction.return_value = AsyncMock() uow.collect_new_events.return_value = [] storage = AsyncMock(spec=ObjectStorage) membership = AsyncMock(spec=ChatMembership) membership.is_member.return_value = True logger = NullLogger() publisher = RecordingPublisher() handler = UploadAttachmentHandler( uow, membership, PillowImageInspector(40_000_000, 1), storage, clock=Mock(spec=Clock, now=Mock(return_value=datetime(2026, 11, 6, tzinfo=UTC))), ids=Mock(spec=IdGenerator, new_id=Mock(side_effect=uuid4)), limit=10_485_760, slots=UploadSlots(1), logger=logger, ) bus = AttachmentsCommandBus({UploadAttachment: handler}, uow, publisher) container = SimpleNamespace(get=AsyncMock(return_value=bus)) owner, chat = uuid4(), uuid4() async def guard(scope: Scope) -> None: scope["state"].update(actor=owner, dishka_container=container) app = FastAPI() app.include_router(uploads_router) install(app, logger, ERROR_CODES, lambda _: "Bearer", "offline-test") transport = ASGITransport( app=RequestPipeline(app, logger, 10_485_760, 5, guard, "offline-test") ) async with AsyncClient(transport=transport, base_url="http://testserver") as http: > response = await http.post( f"/api/v1/chats/{chat}/attachments?filename=broken.png", headers={"Content-Type": "image/png", "X-Request-Id": "png-regression"}, content=data, ) student-tests/unit/test_png_upload.py:68: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .venv/lib/python3.14/site-packages/httpx/_client.py:1859: in post return await self.request( .venv/lib/python3.14/site-packages/httpx/_client.py:1540: in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( .venv/lib/python3.14/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( .venv/lib/python3.14/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/httpx/_transports/asgi.py:170: in handle_async_request await self.app(scope, receive, send) src/messenger/shared/entrypoints/pipeline.py:162: in __call__ await self._app(scope, *pace.around(limited_receive, wrapped_send)) .venv/lib/python3.14/site-packages/fastapi/applications.py:1163: in __call__ await super().__call__(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/applications.py:96: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/middleware/errors.py:186: in __call__ raise exc .venv/lib/python3.14/site-packages/starlette/middleware/errors.py:164: in __call__ await self.app(scope, receive, _send) .venv/lib/python3.14/site-packages/starlette/middleware/exceptions.py:63: in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.14/site-packages/fastapi/middleware/asyncexitstack.py:18: in __call__ await self.app(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/routing.py:676: in __call__ await self.middleware_stack(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:2734: in app await route.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1780: in handle await self.original_router.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:2789: in handle await included_router._handle_selected(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1800: in _handle_selected await original_route.handle(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:1279: in handle await app(scope, receive, send) .venv/lib/python3.14/site-packages/fastapi/routing.py:158: in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:53: in wrapped_app raise exc .venv/lib/python3.14/site-packages/starlette/_exception_handler.py:42: in wrapped_app await app(scope, receive, sender) .venv/lib/python3.14/site-packages/fastapi/routing.py:144: in app response = await f(request) ^^^^^^^^^^^^^^^^ .venv/lib/python3.14/site-packages/fastapi/routing.py:706: in app raw_response = await run_endpoint_function( .venv/lib/python3.14/site-packages/fastapi/routing.py:352: in run_endpoint_function return await dependant.call(**values) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :3: in dishka_func_upload_attachment return await func_upload_attachment(*args, **kwargs, bus=await container.get(AttachmentsCommandBus, '')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/attachments/entrypoints/http.py:42: in upload_attachment attachment = await bus.execute( src/messenger/shared/application/messagebus.py:32: in execute return await handler(command) ^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = command = UploadAttachment(owner_id=UUID('558a343e-816a-4227-9d08-f7218f18b392'), chat_id=UUID('87b01dfc-1d24-480c-a96c-5c8db3ff2847'), filename='broken.png', content_type='image/png', body=) async def __call__(self, command: UploadAttachment) -> Attachment: if not await self._membership.is_member(command.chat_id, command.owner_id): raise ChatNotFound("чат не найден") filename = Filename(command.filename or "") declared = ImageKind.declared(command.content_type) async with self._slots: attachment = await self._write(command, filename, declared) now = self._clock.now() attachment.enqueue(now) job = Job(self._ids.new_id(), attachment.id, self._pipeline_version, 1, now) try: async with self._uow.transaction(): await self._uow.attachments.save(attachment) > await self._uow.jobs.add(job) E TypeError: 'Mock' object can't be awaited src/messenger/attachments/application/handlers.py:98: TypeError ___________________ test_basic_rejects_non_ascii[Basic \x80] ___________________ s = '\x80' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\x80' in position 0: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \x80' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) def test_basic_rejects_non_ascii(raw: bytes) -> None: > assert basic_credentials(raw.decode("latin-1")) is None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ student-tests/unit/test_authentication.py:60: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = '\x80' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError ___________________ test_basic_rejects_non_ascii[Basic \xff] ___________________ s = 'ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \xff' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) def test_basic_rejects_non_ascii(raw: bytes) -> None: > assert basic_credentials(raw.decode("latin-1")) is None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ student-tests/unit/test_authentication.py:60: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError _________________ test_basic_rejects_non_ascii[Basic \xc3\xa9] _________________ s = 'é' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \xc3\xa9' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) def test_basic_rejects_non_ascii(raw: bytes) -> None: > assert basic_credentials(raw.decode("latin-1")) is None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ student-tests/unit/test_authentication.py:60: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'é' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError ___________ test_basic_rejects_non_ascii[Basic YWxpY2U6c2VjcmV0\xff] ___________ s = 'YWxpY2U6c2VjcmV0ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 16: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic YWxpY2U6c2VjcmV0\xff' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) def test_basic_rejects_non_ascii(raw: bytes) -> None: > assert basic_credentials(raw.decode("latin-1")) is None ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ student-tests/unit/test_authentication.py:60: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'YWxpY2U6c2VjcmV0ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError ____ test_non_ascii_basic_returns_401_without_credential_lookup[Basic \x80] ____ s = '\x80' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\x80' in position 0: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \x80' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) async def test_non_ascii_basic_returns_401_without_credential_lookup(raw: bytes) -> None: verify = AsyncMock(return_value=None) container = SimpleNamespace(get=AsyncMock(return_value=verify)) scope: Scope = { "type": "http", "method": "POST", "path": LOGIN_PATH, "headers": [(b"authorization", raw), (b"x-request-id", b"non-ascii-basic")], "app": SimpleNamespace(state=SimpleNamespace(dishka_container=container)), } endpoint, send = AsyncMock(), AsyncMock() pipeline = RequestPipeline(endpoint, Mock(spec=Logger), 1024, 1, guard, "test-instance") > await pipeline(scope, AsyncMock(), send) student-tests/unit/test_authentication.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/shared/entrypoints/pipeline.py:159: in __call__ rejection = await self._guard(scope) or self._oversized(scope, limit) ^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:65: in guard credentials = basic_credentials(raw) ^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = '\x80' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError ____ test_non_ascii_basic_returns_401_without_credential_lookup[Basic \xff] ____ s = 'ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \xff' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) async def test_non_ascii_basic_returns_401_without_credential_lookup(raw: bytes) -> None: verify = AsyncMock(return_value=None) container = SimpleNamespace(get=AsyncMock(return_value=verify)) scope: Scope = { "type": "http", "method": "POST", "path": LOGIN_PATH, "headers": [(b"authorization", raw), (b"x-request-id", b"non-ascii-basic")], "app": SimpleNamespace(state=SimpleNamespace(dishka_container=container)), } endpoint, send = AsyncMock(), AsyncMock() pipeline = RequestPipeline(endpoint, Mock(spec=Logger), 1024, 1, guard, "test-instance") > await pipeline(scope, AsyncMock(), send) student-tests/unit/test_authentication.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/shared/entrypoints/pipeline.py:159: in __call__ rejection = await self._guard(scope) or self._oversized(scope, limit) ^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:65: in guard credentials = basic_credentials(raw) ^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError __ test_non_ascii_basic_returns_401_without_credential_lookup[Basic \xc3\xa9] __ s = 'é' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic \xc3\xa9' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) async def test_non_ascii_basic_returns_401_without_credential_lookup(raw: bytes) -> None: verify = AsyncMock(return_value=None) container = SimpleNamespace(get=AsyncMock(return_value=verify)) scope: Scope = { "type": "http", "method": "POST", "path": LOGIN_PATH, "headers": [(b"authorization", raw), (b"x-request-id", b"non-ascii-basic")], "app": SimpleNamespace(state=SimpleNamespace(dishka_container=container)), } endpoint, send = AsyncMock(), AsyncMock() pipeline = RequestPipeline(endpoint, Mock(spec=Logger), 1024, 1, guard, "test-instance") > await pipeline(scope, AsyncMock(), send) student-tests/unit/test_authentication.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/shared/entrypoints/pipeline.py:159: in __call__ rejection = await self._guard(scope) or self._oversized(scope, limit) ^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:65: in guard credentials = basic_credentials(raw) ^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'é' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError _ test_non_ascii_basic_returns_401_without_credential_lookup[Basic YWxpY2U6c2VjcmV0\xff] _ s = 'YWxpY2U6c2VjcmV0ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: > return s.encode('ascii') ^^^^^^^^^^^^^^^^^ E UnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 16: ordinal not in range(128) ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:34: UnicodeEncodeError During handling of the above exception, another exception occurred: raw = b'Basic YWxpY2U6c2VjcmV0\xff' @pytest.mark.parametrize("raw", NON_ASCII_BASIC) async def test_non_ascii_basic_returns_401_without_credential_lookup(raw: bytes) -> None: verify = AsyncMock(return_value=None) container = SimpleNamespace(get=AsyncMock(return_value=verify)) scope: Scope = { "type": "http", "method": "POST", "path": LOGIN_PATH, "headers": [(b"authorization", raw), (b"x-request-id", b"non-ascii-basic")], "app": SimpleNamespace(state=SimpleNamespace(dishka_container=container)), } endpoint, send = AsyncMock(), AsyncMock() pipeline = RequestPipeline(endpoint, Mock(spec=Logger), 1024, 1, guard, "test-instance") > await pipeline(scope, AsyncMock(), send) student-tests/unit/test_authentication.py:76: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ src/messenger/shared/entrypoints/pipeline.py:159: in __call__ rejection = await self._guard(scope) or self._oversized(scope, limit) ^^^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:65: in guard credentials = basic_credentials(raw) ^^^^^^^^^^^^^^^^^^^^^^ src/messenger/identity/entrypoints/authentication.py:36: in basic_credentials decoded = b64decode(encoded.strip(), validate=True).decode("utf-8") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:80: in b64decode s = _bytes_from_decode_data(s) ^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ s = 'YWxpY2U6c2VjcmV0ÿ' def _bytes_from_decode_data(s): if isinstance(s, str): try: return s.encode('ascii') except UnicodeEncodeError: > raise ValueError('string argument should contain only ASCII characters') E ValueError: string argument should contain only ASCII characters ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/base64.py:36: ValueError ____________________ test_basic_rejects_nul_username[\x00] _____________________ username = '\x00' @pytest.mark.parametrize("username", NUL_TEXTS) def test_basic_rejects_nul_username(username: str) -> None: raw = b64encode(f"{username}:synthetic-password".encode()).decode() > assert basic_credentials(f"Basic {raw}") is None E AssertionError: assert ('\x00', 'synthetic-password') is None E + where ('\x00', 'synthetic-password') = basic_credentials('Basic ADpzeW50aGV0aWMtcGFzc3dvcmQ=') student-tests/unit/test_nul_inputs.py:34: AssertionError ___________________ test_basic_rejects_nul_username[\x00abc] ___________________ username = '\x00abc' @pytest.mark.parametrize("username", NUL_TEXTS) def test_basic_rejects_nul_username(username: str) -> None: raw = b64encode(f"{username}:synthetic-password".encode()).decode() > assert basic_credentials(f"Basic {raw}") is None E AssertionError: assert ('\x00abc', 'synthetic-password') is None E + where ('\x00abc', 'synthetic-password') = basic_credentials('Basic AGFiYzpzeW50aGV0aWMtcGFzc3dvcmQ=') student-tests/unit/test_nul_inputs.py:34: AssertionError _________________ test_basic_rejects_nul_username[abc\x00def] __________________ username = 'abc\x00def' @pytest.mark.parametrize("username", NUL_TEXTS) def test_basic_rejects_nul_username(username: str) -> None: raw = b64encode(f"{username}:synthetic-password".encode()).decode() > assert basic_credentials(f"Basic {raw}") is None E AssertionError: assert ('abc\x00def', 'synthetic-password') is None E + where ('abc\x00def', 'synthetic-password') = basic_credentials('Basic YWJjAGRlZjpzeW50aGV0aWMtcGFzc3dvcmQ=') student-tests/unit/test_nul_inputs.py:34: AssertionError ___________________ test_basic_rejects_nul_username[abc\x00] ___________________ username = 'abc\x00' @pytest.mark.parametrize("username", NUL_TEXTS) def test_basic_rejects_nul_username(username: str) -> None: raw = b64encode(f"{username}:synthetic-password".encode()).decode() > assert basic_credentials(f"Basic {raw}") is None E AssertionError: assert ('abc\x00', 'synthetic-password') is None E + where ('abc\x00', 'synthetic-password') = basic_credentials('Basic YWJjADpzeW50aGV0aWMtcGFzc3dvcmQ=') student-tests/unit/test_nul_inputs.py:34: AssertionError ____________ test_nul_username_is_rejected_before_credential_lookup ____________ async def test_nul_username_is_rejected_before_credential_lookup() -> None: verify = AsyncMock(return_value=None) container = SimpleNamespace(get=AsyncMock(return_value=verify)) scope: Scope = { "method": "POST", "path": LOGIN_PATH, "headers": [(b"authorization", b"Basic " + b64encode(b"abc\x00def:synthetic-password"))], "app": SimpleNamespace(state=SimpleNamespace(dishka_container=container)), } assert await guard(scope) == Rejection( 401, "unauthorized", (("www-authenticate", BASIC_CHALLENGE),) ) container.get.assert_awaited_once_with(VerifyCredentials) > verify.assert_not_awaited() student-tests/unit/test_nul_inputs.py:50: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def assert_not_awaited(self): """ Assert that the mock was never awaited. """ if self.await_count != 0: msg = (f"Expected {self._mock_name or 'mock'} to not have been awaited." f" Awaited {self.await_count} times.") > raise AssertionError(msg) E AssertionError: Expected mock to not have been awaited. Awaited 1 times. ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/unittest/mock.py:2471: AssertionError ________ test_text_values_reject_nul[DisplayName-InvalidUserData-\x00] _________ kind = error = , raw = '\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidUserData student-tests/unit/test_nul_inputs.py:66: Failed _______ test_text_values_reject_nul[DisplayName-InvalidUserData-\x00abc] _______ kind = error = raw = '\x00abc' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidUserData student-tests/unit/test_nul_inputs.py:66: Failed _____ test_text_values_reject_nul[DisplayName-InvalidUserData-abc\x00def] ______ kind = error = raw = 'abc\x00def' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidUserData student-tests/unit/test_nul_inputs.py:66: Failed _______ test_text_values_reject_nul[DisplayName-InvalidUserData-abc\x00] _______ kind = error = raw = 'abc\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidUserData student-tests/unit/test_nul_inputs.py:66: Failed _________ test_text_values_reject_nul[ChatTitle-InvalidChatData-\x00] __________ kind = error = raw = '\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidChatData student-tests/unit/test_nul_inputs.py:66: Failed ________ test_text_values_reject_nul[ChatTitle-InvalidChatData-\x00abc] ________ kind = error = raw = '\x00abc' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidChatData student-tests/unit/test_nul_inputs.py:66: Failed ______ test_text_values_reject_nul[ChatTitle-InvalidChatData-abc\x00def] _______ kind = error = raw = 'abc\x00def' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidChatData student-tests/unit/test_nul_inputs.py:66: Failed ________ test_text_values_reject_nul[ChatTitle-InvalidChatData-abc\x00] ________ kind = error = raw = 'abc\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidChatData student-tests/unit/test_nul_inputs.py:66: Failed _______ test_text_values_reject_nul[MessageText-InvalidMessageText-\x00] _______ kind = error = raw = '\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidMessageText student-tests/unit/test_nul_inputs.py:66: Failed _____ test_text_values_reject_nul[MessageText-InvalidMessageText-\x00abc] ______ kind = error = raw = '\x00abc' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidMessageText student-tests/unit/test_nul_inputs.py:66: Failed ____ test_text_values_reject_nul[MessageText-InvalidMessageText-abc\x00def] ____ kind = error = raw = 'abc\x00def' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidMessageText student-tests/unit/test_nul_inputs.py:66: Failed _____ test_text_values_reject_nul[MessageText-InvalidMessageText-abc\x00] ______ kind = error = raw = 'abc\x00' @pytest.mark.parametrize("raw", NUL_TEXTS) @pytest.mark.parametrize( ("kind", "error"), [ (DisplayName, InvalidUserData), (ChatTitle, InvalidChatData), (MessageText, InvalidMessageText), ], ) def test_text_values_reject_nul( kind: type[DisplayName | ChatTitle | MessageText], error: type[DomainError], raw: str ) -> None: > with pytest.raises(error): ^^^^^^^^^^^^^^^^^^^^ E Failed: DID NOT RAISE InvalidMessageText student-tests/unit/test_nul_inputs.py:66: Failed ____________ test_nul_message_checks_access_without_writing[False] _____________ member = False @pytest.mark.parametrize("member", [False, True]) async def test_nul_message_checks_access_without_writing(member: bool) -> None: chats = AsyncMock(spec=ChatDirectory) chats.chat_for_member.return_value = Mock() if member else None log = AsyncMock(spec=MessageLog) log.post.return_value = None uow = Mock(spec=MessagingUnitOfWork) clock = Mock(spec=Clock) clock.now.return_value = datetime(2026, 1, 1, tzinfo=UTC) handler = PostMessageHandler( uow, log, chats, clock, Mock(spec=IdGenerator), ttl=timedelta(days=1) ) command = PostMessage(uuid4(), uuid4(), "abc\x00def", "same-key", b"fingerprint") with pytest.raises(InvalidMessageText if member else ChatNotFound): await handler(command) > chats.chat_for_member.assert_awaited_once_with(command.chat_id, command.sender_id) student-tests/unit/test_nul_inputs.py:93: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = args = (UUID('c17c3466-11f1-4640-aaaf-198c327a128a'), UUID('fa7a1f7f-d383-4fc4-bf36-04ce8c5a3c38')) kwargs = {} def assert_awaited_once_with(self, /, *args, **kwargs): """ Assert that the mock was awaited exactly once and with the specified arguments. """ if not self.await_count == 1: msg = (f"Expected {self._mock_name or 'mock'} to have been awaited once." f" Awaited {self.await_count} times.") > raise AssertionError(msg) E AssertionError: Expected chat_for_member to have been awaited once. Awaited 0 times. ../../../../../.local/share/uv/python/cpython-3.14.5-macos-aarch64-none/lib/python3.14/unittest/mock.py:2404: AssertionError _____________ test_nul_message_checks_access_without_writing[True] _____________ member = True @pytest.mark.parametrize("member", [False, True]) async def test_nul_message_checks_access_without_writing(member: bool) -> None: chats = AsyncMock(spec=ChatDirectory) chats.chat_for_member.return_value = Mock() if member else None log = AsyncMock(spec=MessageLog) log.post.return_value = None uow = Mock(spec=MessagingUnitOfWork) clock = Mock(spec=Clock) clock.now.return_value = datetime(2026, 1, 1, tzinfo=UTC) handler = PostMessageHandler( uow, log, chats, clock, Mock(spec=IdGenerator), ttl=timedelta(days=1) ) command = PostMessage(uuid4(), uuid4(), "abc\x00def", "same-key", b"fingerprint") with pytest.raises(InvalidMessageText if member else ChatNotFound): > await handler(command) student-tests/unit/test_nul_inputs.py:92: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = command = PostMessage(sender_id=UUID('2f6bf540-5c3b-4cc3-bf29-86ddd9149c2c'), chat_id=UUID('ff9ff68b-4307-4ef9-bb59-d4c9c6150d45'), text='abc\x00def', key='same-key', fingerprint=b'fingerprint', attachment_ids=()) async def __call__(self, command: PostMessage) -> Message: try: text = MessageText(command.text) attachments = attachment_list(text, command.attachment_ids) except InvalidMessageText, InvalidAttachmentList: if await self._chats.chat_for_member(command.chat_id, command.sender_id) is None: raise ChatNotFound("чат не найден") from None raise now = self._clock.now() draft = Message( self._ids.new_id(), command.chat_id, command.sender_id, text, now, attachments ) receipt = await self._log.post(draft, command.key, command.fingerprint, now - self._ttl) if receipt is None: > raise ChatNotFound("чат не найден") E messenger.messaging.domain.errors.ChatNotFound: чат не найден src/messenger/messaging/application/handlers.py:71: ChatNotFound =========================== short test summary info ============================ FAILED student-tests/unit/test_png_upload.py::test_broken_png_returns_415_before_any_storage_write[bad-zlib] FAILED student-tests/unit/test_png_upload.py::test_broken_png_returns_415_before_any_storage_write[duplicate-ihdr] FAILED student-tests/unit/test_authentication.py::test_basic_rejects_non_ascii[Basic \x80] FAILED student-tests/unit/test_authentication.py::test_basic_rejects_non_ascii[Basic \xff] FAILED student-tests/unit/test_authentication.py::test_basic_rejects_non_ascii[Basic \xc3\xa9] FAILED student-tests/unit/test_authentication.py::test_basic_rejects_non_ascii[Basic YWxpY2U6c2VjcmV0\xff] FAILED student-tests/unit/test_authentication.py::test_non_ascii_basic_returns_401_without_credential_lookup[Basic \x80] FAILED student-tests/unit/test_authentication.py::test_non_ascii_basic_returns_401_without_credential_lookup[Basic \xff] FAILED student-tests/unit/test_authentication.py::test_non_ascii_basic_returns_401_without_credential_lookup[Basic \xc3\xa9] FAILED student-tests/unit/test_authentication.py::test_non_ascii_basic_returns_401_without_credential_lookup[Basic YWxpY2U6c2VjcmV0\xff] FAILED student-tests/unit/test_nul_inputs.py::test_basic_rejects_nul_username[\x00] FAILED student-tests/unit/test_nul_inputs.py::test_basic_rejects_nul_username[\x00abc] FAILED student-tests/unit/test_nul_inputs.py::test_basic_rejects_nul_username[abc\x00def] FAILED student-tests/unit/test_nul_inputs.py::test_basic_rejects_nul_username[abc\x00] FAILED student-tests/unit/test_nul_inputs.py::test_nul_username_is_rejected_before_credential_lookup FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[DisplayName-InvalidUserData-\x00] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[DisplayName-InvalidUserData-\x00abc] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[DisplayName-InvalidUserData-abc\x00def] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[DisplayName-InvalidUserData-abc\x00] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[ChatTitle-InvalidChatData-\x00] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[ChatTitle-InvalidChatData-\x00abc] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[ChatTitle-InvalidChatData-abc\x00def] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[ChatTitle-InvalidChatData-abc\x00] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[MessageText-InvalidMessageText-\x00] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[MessageText-InvalidMessageText-\x00abc] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[MessageText-InvalidMessageText-abc\x00def] FAILED student-tests/unit/test_nul_inputs.py::test_text_values_reject_nul[MessageText-InvalidMessageText-abc\x00] FAILED student-tests/unit/test_nul_inputs.py::test_nul_message_checks_access_without_writing[False] FAILED student-tests/unit/test_nul_inputs.py::test_nul_message_checks_access_without_writing[True] 29 failed, 24 passed in 0.57s exit_code: 1 elapsed_seconds: 1.187