From 28bca0b270600dd0d555a6d86465544b20b5500c Mon Sep 17 00:00:00 2001 From: thefankor Date: Sat, 24 Oct 2026 13:07:35 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20not=5Fblank=20=D0=BD=D0=B0=20=D0=BF=D0=B0=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/schemas.py | 4 ++-- tests/test_validation.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/api/schemas.py b/app/api/schemas.py index 145b0c0c..6b3752b7 100644 --- a/app/api/schemas.py +++ b/app/api/schemas.py @@ -34,9 +34,9 @@ class CreateUser(Strict): display_name: str = Field(min_length=1, max_length=NAME_MAX) password: str = Field(min_length=12, max_length=128) - @field_validator('display_name') + @field_validator('display_name', 'password') @classmethod - def _display_name(cls, value: str) -> str: + def _not_blank(cls, value: str) -> str: return not_blank(value) diff --git a/tests/test_validation.py b/tests/test_validation.py index 5c02c4a0..85c98656 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -10,6 +10,14 @@ def test_rejects_duplicate_username(actors): client.call('POST', '/api/v1/users', 409, body=alice['registration']) +def test_rejects_blank_password(client): + response = client.call( + 'POST', '/api/v1/users', 400, + body={'username': 'blank_password', 'display_name': 'Blank password', 'password': ' ' * 12}, + ) + assert response['json']['error']['code'] == 'invalid_request' + + def test_hides_chat_from_outsider(actors): client, _, _, eve, chat = actors client.call('GET', '/api/v1/chats/' + chat['id'], 404, actor=eve)