forked from mtusi2026/mtusi2026lab2
fix: добавлена проверка not_blank на пароль
This commit is contained in:
+2
-2
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user