forked from mtusi2026/mtusi2026lab2
fix whitespace and NULL validation
This commit is contained in:
+14
-2
@@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
from datetime import UTC, datetime, timedelta
|
from datetime import UTC, datetime, timedelta
|
||||||
|
|
||||||
from redis.asyncio import Redis
|
from redis.asyncio import Redis
|
||||||
@@ -7,10 +8,17 @@ from app.core import security
|
|||||||
from app.domain.users import to_user_schema
|
from app.domain.users import to_user_schema
|
||||||
from app.errors.exceptions import unauthorized_basic, unauthorized_bearer
|
from app.errors.exceptions import unauthorized_basic, unauthorized_bearer
|
||||||
from app.schemas.session import AuthSession
|
from app.schemas.session import AuthSession
|
||||||
from app.schemas.user import PASSWORD_MAX_LENGTH, PASSWORD_MIN_LENGTH, User
|
from app.schemas.user import (
|
||||||
|
PASSWORD_MAX_LENGTH,
|
||||||
|
PASSWORD_MIN_LENGTH,
|
||||||
|
USERNAME_PATTERN,
|
||||||
|
User,
|
||||||
|
)
|
||||||
from app.storage import sessions as sessions_storage
|
from app.storage import sessions as sessions_storage
|
||||||
from app.storage import users as users_storage
|
from app.storage import users as users_storage
|
||||||
|
|
||||||
|
USERNAME_RE = re.compile(USERNAME_PATTERN)
|
||||||
|
|
||||||
|
|
||||||
async def create_session(
|
async def create_session(
|
||||||
session: AsyncSession,
|
session: AsyncSession,
|
||||||
@@ -20,7 +28,11 @@ async def create_session(
|
|||||||
ttl_seconds: int,
|
ttl_seconds: int,
|
||||||
) -> AuthSession:
|
) -> AuthSession:
|
||||||
"""Проверяет учётные данные и выдаёт новый Bearer-токен."""
|
"""Проверяет учётные данные и выдаёт новый Bearer-токен."""
|
||||||
if not PASSWORD_MIN_LENGTH <= len(password) <= PASSWORD_MAX_LENGTH:
|
if (
|
||||||
|
USERNAME_RE.fullmatch(username) is None
|
||||||
|
or not PASSWORD_MIN_LENGTH <= len(password) <= PASSWORD_MAX_LENGTH
|
||||||
|
or not password.strip()
|
||||||
|
):
|
||||||
raise unauthorized_basic()
|
raise unauthorized_basic()
|
||||||
|
|
||||||
user = await users_storage.get_user_by_username(session, username)
|
user = await users_storage.get_user_by_username(session, username)
|
||||||
|
|||||||
+9
-9
@@ -1,7 +1,7 @@
|
|||||||
from typing import ClassVar, Literal
|
from typing import Literal
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, ValidationInfo, field_validator
|
from pydantic import BaseModel, ConfigDict, field_validator
|
||||||
|
|
||||||
|
|
||||||
class Base(BaseModel):
|
class Base(BaseModel):
|
||||||
@@ -19,15 +19,15 @@ class Health(BaseModel):
|
|||||||
class BaseCreate(BaseModel):
|
class BaseCreate(BaseModel):
|
||||||
model_config = ConfigDict(extra="forbid")
|
model_config = ConfigDict(extra="forbid")
|
||||||
|
|
||||||
blank_allowed_fields: ClassVar[frozenset[str]] = frozenset({"password"})
|
|
||||||
|
|
||||||
@field_validator("*", mode="before")
|
@field_validator("*", mode="before")
|
||||||
@classmethod
|
@classmethod
|
||||||
def reject_blank_strings(cls, value: object, info: ValidationInfo) -> object:
|
def reject_invalid_strings(cls, value: object) -> object:
|
||||||
if info.field_name in cls.blank_allowed_fields:
|
"""Отклоняет строки из одних пробелов и строки с NUL, который не хранит PostgreSQL."""
|
||||||
return value
|
if isinstance(value, str):
|
||||||
if isinstance(value, str) and not value.strip():
|
if not value.strip():
|
||||||
raise ValueError("Строка не может состоять только из пробелов")
|
raise ValueError("Строка не может состоять только из пробелов")
|
||||||
|
if "\x00" in value:
|
||||||
|
raise ValueError("Строка не может содержать символ NUL")
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -4,6 +4,7 @@ from pydantic import Field
|
|||||||
|
|
||||||
from app.schemas.base import Base, BaseCreate
|
from app.schemas.base import Base, BaseCreate
|
||||||
|
|
||||||
|
USERNAME_PATTERN = r"^[a-z0-9_]{3,32}$"
|
||||||
PASSWORD_MIN_LENGTH = 12
|
PASSWORD_MIN_LENGTH = 12
|
||||||
PASSWORD_MAX_LENGTH = 128
|
PASSWORD_MAX_LENGTH = 128
|
||||||
|
|
||||||
@@ -11,13 +12,13 @@ PASSWORD_MAX_LENGTH = 128
|
|||||||
class User(Base):
|
class User(Base):
|
||||||
"""Публичное представление пользователя. Пароль/хеш сюда не попадают никогда."""
|
"""Публичное представление пользователя. Пароль/хеш сюда не попадают никогда."""
|
||||||
|
|
||||||
username: str = Field(pattern=r"^[a-z0-9_]{3,32}$")
|
username: str = Field(pattern=USERNAME_PATTERN)
|
||||||
display_name: str = Field(min_length=1, max_length=100)
|
display_name: str = Field(min_length=1, max_length=100)
|
||||||
created_at: datetime
|
created_at: datetime
|
||||||
|
|
||||||
|
|
||||||
class CreateUser(BaseCreate):
|
class CreateUser(BaseCreate):
|
||||||
username: str = Field(pattern=r"^[a-z0-9_]{3,32}$")
|
username: str = Field(pattern=USERNAME_PATTERN)
|
||||||
display_name: str = Field(min_length=1, max_length=100)
|
display_name: str = Field(min_length=1, max_length=100)
|
||||||
password: str = Field(
|
password: str = Field(
|
||||||
min_length=PASSWORD_MIN_LENGTH, max_length=PASSWORD_MAX_LENGTH, repr=False
|
min_length=PASSWORD_MIN_LENGTH, max_length=PASSWORD_MAX_LENGTH, repr=False
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
date: 2026-10-26T21:33:23Z
|
date: 2026-10-28T17:22:39Z
|
||||||
commit: f55710c
|
commit: e3b3163 (+ uncommitted changes)
|
||||||
branch: solution/BPI2303-Grigoryan
|
branch: solution/BPI2303-Grigoryan
|
||||||
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz (8 threads)
|
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz (8 threads)
|
||||||
memory: 15Gi
|
memory: 15Gi
|
||||||
@@ -12,4 +12,4 @@ stand: http://localhost:18080 (compose project mtusi2026lab2-fork-test)
|
|||||||
SERVICE IMAGE STATUS
|
SERVICE IMAGE STATUS
|
||||||
api mtusi-messenger:lab2 Up 2 seconds (health: starting)
|
api mtusi-messenger:lab2 Up 2 seconds (health: starting)
|
||||||
postgres postgres:16.10-bookworm Up 9 seconds (healthy)
|
postgres postgres:16.10-bookworm Up 9 seconds (healthy)
|
||||||
redis redis:7.4.2-bookworm Up 10 seconds (healthy)
|
redis redis:7.4.2-bookworm Up 9 seconds (healthy)
|
||||||
|
|||||||
+93
-84
@@ -3,32 +3,35 @@ tests/test_auth.py::test_each_login_issues_a_different_token PASSED [ 1%]
|
|||||||
tests/test_auth.py::test_password_with_colon_works PASSED [ 2%]
|
tests/test_auth.py::test_password_with_colon_works PASSED [ 2%]
|
||||||
tests/test_auth.py::test_unicode_password_works PASSED [ 3%]
|
tests/test_auth.py::test_unicode_password_works PASSED [ 3%]
|
||||||
tests/test_auth.py::test_wrong_password_and_unknown_user_look_identical PASSED [ 4%]
|
tests/test_auth.py::test_wrong_password_and_unknown_user_look_identical PASSED [ 4%]
|
||||||
tests/test_auth.py::test_login_requires_basic_scheme PASSED [ 5%]
|
tests/test_auth.py::test_login_requires_basic_scheme PASSED [ 4%]
|
||||||
tests/test_auth.py::test_business_endpoints_require_bearer PASSED [ 6%]
|
tests/test_auth.py::test_business_endpoints_require_bearer PASSED [ 5%]
|
||||||
tests/test_auth.py::test_x_user_id_cannot_override_bearer_identity PASSED [ 7%]
|
tests/test_auth.py::test_x_user_id_cannot_override_bearer_identity PASSED [ 6%]
|
||||||
tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 8%]
|
tests/test_auth.py::test_logout_revokes_only_current_session PASSED [ 7%]
|
||||||
tests/test_auth.py::test_logout_twice_returns_401 PASSED [ 8%]
|
tests/test_auth.py::test_logout_twice_returns_401 PASSED [ 8%]
|
||||||
tests/test_auth.py::test_session_expires_after_ttl PASSED [ 9%]
|
tests/test_auth.py::test_session_expires_after_ttl PASSED [ 9%]
|
||||||
tests/test_auth.py::test_token_is_stored_only_as_sha256_key PASSED [ 10%]
|
tests/test_auth.py::test_token_is_stored_only_as_sha256_key PASSED [ 9%]
|
||||||
tests/test_auth.py::test_password_is_not_stored_in_plaintext PASSED [ 11%]
|
tests/test_auth.py::test_password_is_not_stored_in_plaintext PASSED [ 10%]
|
||||||
tests/test_auth.py::test_login_rejects_out_of_range_password_like_wrong_password PASSED [ 12%]
|
tests/test_auth.py::test_login_rejects_out_of_range_password_like_wrong_password PASSED [ 11%]
|
||||||
tests/test_auth.py::test_malformed_basic_credentials_return_401 PASSED [ 13%]
|
tests/test_auth.py::test_malformed_basic_credentials_return_401 PASSED [ 12%]
|
||||||
tests/test_auth.py::test_unknown_user_takes_comparable_time_to_wrong_password PASSED [ 14%]
|
tests/test_auth.py::test_unknown_user_takes_comparable_time_to_wrong_password PASSED [ 13%]
|
||||||
|
tests/test_auth.py::test_invalid_basic_username_returns_401_not_500 PASSED [ 14%]
|
||||||
|
tests/test_auth.py::test_whitespace_only_password_at_login_returns_401 PASSED [ 14%]
|
||||||
tests/test_chats.py::test_create_and_get_chat PASSED [ 15%]
|
tests/test_chats.py::test_create_and_get_chat PASSED [ 15%]
|
||||||
tests/test_chats.py::test_chat_is_not_visible_to_outsider PASSED [ 16%]
|
tests/test_chats.py::test_chat_is_not_visible_to_outsider PASSED [ 16%]
|
||||||
tests/test_chats.py::test_chat_creation_requires_creator_in_members PASSED [ 16%]
|
tests/test_chats.py::test_chat_creation_requires_creator_in_members PASSED [ 17%]
|
||||||
tests/test_chats.py::test_chat_payload_boundaries[payload0] PASSED [ 17%]
|
tests/test_chats.py::test_chat_payload_boundaries[payload0] PASSED [ 18%]
|
||||||
tests/test_chats.py::test_chat_payload_boundaries[payload1] PASSED [ 18%]
|
tests/test_chats.py::test_chat_payload_boundaries[payload1] PASSED [ 19%]
|
||||||
tests/test_chats.py::test_duplicate_members_are_rejected PASSED [ 19%]
|
tests/test_chats.py::test_duplicate_members_are_rejected PASSED [ 19%]
|
||||||
tests/test_chats.py::test_unknown_member_is_rejected PASSED [ 20%]
|
tests/test_chats.py::test_unknown_member_is_rejected PASSED [ 20%]
|
||||||
tests/test_chats.py::test_chat_exact_title_limit_is_accepted PASSED [ 21%]
|
tests/test_chats.py::test_chat_exact_title_limit_is_accepted PASSED [ 21%]
|
||||||
tests/test_chats.py::test_chat_list_hides_chats_without_membership PASSED [ 22%]
|
tests/test_chats.py::test_chat_list_hides_chats_without_membership PASSED [ 22%]
|
||||||
tests/test_chats.py::test_nonexistent_chat_returns_404 PASSED [ 23%]
|
tests/test_chats.py::test_nonexistent_chat_returns_404 PASSED [ 23%]
|
||||||
tests/test_chats.py::test_failed_chat_creation_leaves_no_partial_data PASSED [ 24%]
|
tests/test_chats.py::test_failed_chat_creation_leaves_no_partial_data PASSED [ 23%]
|
||||||
tests/test_chats.py::test_chat_list_pagination_and_order PASSED [ 25%]
|
tests/test_chats.py::test_chat_list_pagination_and_order PASSED [ 24%]
|
||||||
tests/test_chats.py::test_chat_endpoints_require_bearer PASSED [ 25%]
|
tests/test_chats.py::test_chat_endpoints_require_bearer PASSED [ 25%]
|
||||||
tests/test_concurrency.py::test_parallel_registration_of_same_username_creates_exactly_one_user PASSED [ 26%]
|
tests/test_chats.py::test_nul_in_chat_title_is_rejected PASSED [ 26%]
|
||||||
tests/test_concurrency.py::test_100_messages_from_10_clients PASSED [ 27%]
|
tests/test_concurrency.py::test_parallel_registration_of_same_username_creates_exactly_one_user PASSED [ 27%]
|
||||||
|
tests/test_concurrency.py::test_100_messages_from_10_clients PASSED [ 28%]
|
||||||
tests/test_concurrency.py::test_chat_creation_in_parallel_is_atomic PASSED [ 28%]
|
tests/test_concurrency.py::test_chat_creation_in_parallel_is_atomic PASSED [ 28%]
|
||||||
tests/test_concurrency.py::test_parallel_registration_of_distinct_usernames_all_succeed PASSED [ 29%]
|
tests/test_concurrency.py::test_parallel_registration_of_distinct_usernames_all_succeed PASSED [ 29%]
|
||||||
tests/test_concurrency.py::test_parallel_logins_issue_distinct_valid_tokens PASSED [ 30%]
|
tests/test_concurrency.py::test_parallel_logins_issue_distinct_valid_tokens PASSED [ 30%]
|
||||||
@@ -41,73 +44,79 @@ tests/test_constraints.py::test_duplicate_membership_is_rejected_by_database PAS
|
|||||||
tests/test_errors.py::test_missing_token_returns_401 PASSED [ 36%]
|
tests/test_errors.py::test_missing_token_returns_401 PASSED [ 36%]
|
||||||
tests/test_errors.py::test_garbage_token_returns_401 PASSED [ 37%]
|
tests/test_errors.py::test_garbage_token_returns_401 PASSED [ 37%]
|
||||||
tests/test_errors.py::test_malformed_json_returns_400 PASSED [ 38%]
|
tests/test_errors.py::test_malformed_json_returns_400 PASSED [ 38%]
|
||||||
tests/test_errors.py::test_not_found_returns_404 PASSED [ 39%]
|
tests/test_errors.py::test_not_found_returns_404 PASSED [ 38%]
|
||||||
tests/test_errors.py::test_method_not_allowed_preserves_405 PASSED [ 40%]
|
tests/test_errors.py::test_method_not_allowed_preserves_405 PASSED [ 39%]
|
||||||
tests/test_errors.py::test_unhandled_exception_is_hidden_from_client PASSED [ 41%]
|
tests/test_errors.py::test_unhandled_exception_is_hidden_from_client PASSED [ 40%]
|
||||||
tests/test_errors.py::test_success_response_contains_request_id PASSED [ 41%]
|
tests/test_errors.py::test_success_response_contains_request_id PASSED [ 41%]
|
||||||
tests/test_failures.py::test_redis_down_gives_503_for_login_and_protected_endpoints PASSED [ 42%]
|
tests/test_failures.py::test_redis_down_gives_503_for_login_and_protected_endpoints PASSED [ 42%]
|
||||||
tests/test_failures.py::test_redis_down_keeps_registration_working PASSED [ 43%]
|
tests/test_failures.py::test_redis_down_keeps_registration_working PASSED [ 42%]
|
||||||
tests/test_failures.py::test_database_down_with_valid_session_gives_503 PASSED [ 44%]
|
tests/test_failures.py::test_database_down_with_valid_session_gives_503 PASSED [ 43%]
|
||||||
tests/test_failures.py::test_dependency_failure_never_authenticates_anonymous_requests PASSED [ 45%]
|
tests/test_failures.py::test_dependency_failure_never_authenticates_anonymous_requests PASSED [ 44%]
|
||||||
tests/test_health.py::test_liveness PASSED [ 46%]
|
tests/test_health.py::test_liveness PASSED [ 45%]
|
||||||
tests/test_health.py::test_readiness PASSED [ 47%]
|
tests/test_health.py::test_readiness PASSED [ 46%]
|
||||||
tests/test_health.py::test_readiness_is_503_when_database_is_down PASSED [ 48%]
|
tests/test_health.py::test_readiness_is_503_when_database_is_down PASSED [ 47%]
|
||||||
tests/test_health.py::test_business_request_is_503_when_database_is_down PASSED [ 49%]
|
tests/test_health.py::test_business_request_is_503_when_database_is_down PASSED [ 47%]
|
||||||
tests/test_history_plan.py::test_history_page_uses_composite_index PASSED [ 50%]
|
tests/test_history_plan.py::test_history_page_uses_composite_index PASSED [ 48%]
|
||||||
tests/test_limits.py::test_message_limit_rejects_without_deleting_confirmed_messages PASSED [ 50%]
|
tests/test_limits.py::test_message_limit_rejects_without_deleting_confirmed_messages PASSED [ 49%]
|
||||||
tests/test_limits.py::test_in_flight_limit_returns_429_and_recovers PASSED [ 51%]
|
tests/test_limits.py::test_in_flight_limit_returns_429_and_recovers PASSED [ 50%]
|
||||||
tests/test_messages.py::test_send_and_list_message PASSED [ 52%]
|
tests/test_messages.py::test_send_and_list_message PASSED [ 51%]
|
||||||
tests/test_messages.py::test_invalid_message_text[] PASSED [ 53%]
|
tests/test_messages.py::test_invalid_message_text[] PASSED [ 52%]
|
||||||
tests/test_messages.py::test_invalid_message_text[ ] PASSED [ 54%]
|
tests/test_messages.py::test_invalid_message_text[ ] PASSED [ 52%]
|
||||||
tests/test_messages.py::test_invalid_message_text[xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] PASSED [ 53%]
|
||||||
tests/test_messages.py::test_extra_message_field_is_rejected PASSED [ 56%]
|
tests/test_messages.py::test_extra_message_field_is_rejected PASSED [ 54%]
|
||||||
tests/test_messages.py::test_messages_are_private_to_chat_members PASSED [ 57%]
|
tests/test_messages.py::test_messages_are_private_to_chat_members PASSED [ 55%]
|
||||||
tests/test_messages.py::test_pagination_has_no_duplicates PASSED [ 58%]
|
tests/test_messages.py::test_pagination_has_no_duplicates PASSED [ 56%]
|
||||||
tests/test_messages.py::test_cursor_cannot_be_used_for_another_chat PASSED [ 58%]
|
tests/test_messages.py::test_cursor_cannot_be_used_for_another_chat PASSED [ 57%]
|
||||||
tests/test_messages.py::test_limit_boundaries[0-400] PASSED [ 59%]
|
tests/test_messages.py::test_limit_boundaries[0-400] PASSED [ 57%]
|
||||||
tests/test_messages.py::test_limit_boundaries[1-200] PASSED [ 60%]
|
tests/test_messages.py::test_limit_boundaries[1-200] PASSED [ 58%]
|
||||||
tests/test_messages.py::test_limit_boundaries[100-200] PASSED [ 61%]
|
tests/test_messages.py::test_limit_boundaries[100-200] PASSED [ 59%]
|
||||||
tests/test_messages.py::test_limit_boundaries[101-400] PASSED [ 62%]
|
tests/test_messages.py::test_limit_boundaries[101-400] PASSED [ 60%]
|
||||||
tests/test_messages.py::test_message_exact_max_length_is_accepted PASSED [ 63%]
|
tests/test_messages.py::test_message_exact_max_length_is_accepted PASSED [ 61%]
|
||||||
tests/test_messages.py::test_nonexistent_chat_messages_return_404 PASSED [ 64%]
|
tests/test_messages.py::test_nonexistent_chat_messages_return_404 PASSED [ 61%]
|
||||||
tests/test_messages.py::test_unauthenticated_requests_are_rejected PASSED [ 65%]
|
tests/test_messages.py::test_unauthenticated_requests_are_rejected PASSED [ 62%]
|
||||||
tests/test_messages.py::test_messages_survive_new_login PASSED [ 66%]
|
tests/test_messages.py::test_messages_survive_new_login PASSED [ 63%]
|
||||||
tests/test_messages.py::test_history_order_is_created_at_then_id PASSED [ 66%]
|
tests/test_messages.py::test_history_order_is_created_at_then_id PASSED [ 64%]
|
||||||
tests/test_migrations.py::test_upgrade_creates_all_tables PASSED [ 67%]
|
tests/test_messages.py::test_nul_in_message_text_is_rejected PASSED [ 65%]
|
||||||
tests/test_migrations.py::test_upgrade_twice_is_idempotent_and_keeps_data PASSED [ 68%]
|
tests/test_migrations.py::test_upgrade_creates_all_tables PASSED [ 66%]
|
||||||
tests/test_migrations.py::test_models_and_migrations_are_in_sync PASSED [ 69%]
|
tests/test_migrations.py::test_upgrade_twice_is_idempotent_and_keeps_data PASSED [ 66%]
|
||||||
tests/test_pagination.py::test_garbage_cursor_returns_400[not-base64-%%%] PASSED [ 70%]
|
tests/test_migrations.py::test_models_and_migrations_are_in_sync PASSED [ 67%]
|
||||||
tests/test_pagination.py::test_garbage_cursor_returns_400[bm90IGpzb24=] PASSED [ 71%]
|
tests/test_pagination.py::test_garbage_cursor_returns_400[not-base64-%%%] PASSED [ 68%]
|
||||||
tests/test_pagination.py::test_garbage_cursor_returns_400[WzEsIDIsIDNd] PASSED [ 72%]
|
tests/test_pagination.py::test_garbage_cursor_returns_400[bm90IGpzb24=] PASSED [ 69%]
|
||||||
tests/test_pagination.py::test_garbage_cursor_returns_400[eyJraW5kIjogIm1lc3NhZ2VzIn0=] PASSED [ 73%]
|
tests/test_pagination.py::test_garbage_cursor_returns_400[WzEsIDIsIDNd] PASSED [ 70%]
|
||||||
tests/test_pagination.py::test_cursor_without_timezone_is_rejected PASSED [ 74%]
|
tests/test_pagination.py::test_garbage_cursor_returns_400[eyJraW5kIjogIm1lc3NhZ2VzIn0=] PASSED [ 71%]
|
||||||
tests/test_pagination.py::test_chat_list_cursor_is_bound_to_its_owner PASSED [ 75%]
|
tests/test_pagination.py::test_cursor_without_timezone_is_rejected PASSED [ 71%]
|
||||||
tests/test_pagination.py::test_messages_cursor_is_not_accepted_by_chat_list PASSED [ 75%]
|
tests/test_pagination.py::test_chat_list_cursor_is_bound_to_its_owner PASSED [ 72%]
|
||||||
tests/test_pagination.py::test_limit_can_change_between_pages PASSED [ 76%]
|
tests/test_pagination.py::test_messages_cursor_is_not_accepted_by_chat_list PASSED [ 73%]
|
||||||
tests/test_pagination.py::test_message_sent_after_reading_last_page_is_seen_with_cursor PASSED [ 77%]
|
tests/test_pagination.py::test_limit_can_change_between_pages PASSED [ 74%]
|
||||||
tests/test_sessions.py::test_session_key_ttl_matches_expires_at PASSED [ 78%]
|
tests/test_pagination.py::test_message_sent_after_reading_last_page_is_seen_with_cursor PASSED [ 75%]
|
||||||
tests/test_sessions.py::test_session_ttl_is_absolute_and_not_extended_by_activity PASSED [ 79%]
|
tests/test_sessions.py::test_session_key_ttl_matches_expires_at PASSED [ 76%]
|
||||||
tests/test_sessions.py::test_logout_removes_session_key PASSED [ 80%]
|
tests/test_sessions.py::test_session_ttl_is_absolute_and_not_extended_by_activity PASSED [ 76%]
|
||||||
tests/test_sessions.py::test_expired_session_is_rejected_everywhere PASSED [ 81%]
|
tests/test_sessions.py::test_logout_removes_session_key PASSED [ 77%]
|
||||||
tests/test_sessions.py::test_relogin_after_expiry_issues_new_working_token PASSED [ 82%]
|
tests/test_sessions.py::test_expired_session_is_rejected_everywhere PASSED [ 78%]
|
||||||
tests/test_sessions.py::test_tampered_token_is_rejected PASSED [ 83%]
|
tests/test_sessions.py::test_relogin_after_expiry_issues_new_working_token PASSED [ 79%]
|
||||||
tests/test_sessions.py::test_session_of_deleted_user_is_rejected PASSED [ 83%]
|
tests/test_sessions.py::test_tampered_token_is_rejected PASSED [ 80%]
|
||||||
tests/test_sessions.py::test_redis_flush_invalidates_all_sessions PASSED [ 84%]
|
tests/test_sessions.py::test_session_of_deleted_user_is_rejected PASSED [ 80%]
|
||||||
tests/test_sessions.py::test_sessions_survive_redis_restart PASSED [ 85%]
|
tests/test_sessions.py::test_redis_flush_invalidates_all_sessions PASSED [ 81%]
|
||||||
tests/test_users.py::test_register_does_not_leak_password PASSED [ 86%]
|
tests/test_sessions.py::test_sessions_survive_redis_restart PASSED [ 82%]
|
||||||
tests/test_users.py::test_get_current_user PASSED [ 87%]
|
tests/test_users.py::test_register_does_not_leak_password PASSED [ 83%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body0] PASSED [ 88%]
|
tests/test_users.py::test_get_current_user PASSED [ 84%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body1] PASSED [ 89%]
|
tests/test_users.py::test_invalid_user_payloads[body0] PASSED [ 85%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body2] PASSED [ 90%]
|
tests/test_users.py::test_invalid_user_payloads[body1] PASSED [ 85%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body3] PASSED [ 91%]
|
tests/test_users.py::test_invalid_user_payloads[body2] PASSED [ 86%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body4] PASSED [ 91%]
|
tests/test_users.py::test_invalid_user_payloads[body3] PASSED [ 87%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body5] PASSED [ 92%]
|
tests/test_users.py::test_invalid_user_payloads[body4] PASSED [ 88%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body6] PASSED [ 93%]
|
tests/test_users.py::test_invalid_user_payloads[body5] PASSED [ 89%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body7] PASSED [ 94%]
|
tests/test_users.py::test_invalid_user_payloads[body6] PASSED [ 90%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body8] PASSED [ 95%]
|
tests/test_users.py::test_invalid_user_payloads[body7] PASSED [ 90%]
|
||||||
tests/test_users.py::test_invalid_user_payloads[body9] PASSED [ 96%]
|
tests/test_users.py::test_invalid_user_payloads[body8] PASSED [ 91%]
|
||||||
tests/test_users.py::test_password_length_boundaries_are_accepted PASSED [ 97%]
|
tests/test_users.py::test_invalid_user_payloads[body9] PASSED [ 92%]
|
||||||
tests/test_users.py::test_extra_user_field_is_rejected PASSED [ 98%]
|
tests/test_users.py::test_password_length_boundaries_are_accepted PASSED [ 93%]
|
||||||
tests/test_users.py::test_duplicate_username_returns_conflict PASSED [ 99%]
|
tests/test_users.py::test_extra_user_field_is_rejected PASSED [ 94%]
|
||||||
tests/test_users.py::test_user_exact_length_boundaries_are_accepted PASSED [100%]
|
tests/test_users.py::test_duplicate_username_returns_conflict PASSED [ 95%]
|
||||||
============================= 112 passed in 38.60s =============================
|
tests/test_users.py::test_user_exact_length_boundaries_are_accepted PASSED [ 95%]
|
||||||
|
tests/test_users.py::test_whitespace_only_password_is_rejected[ ] PASSED [ 96%]
|
||||||
|
tests/test_users.py::test_whitespace_only_password_is_rejected[\t\t\t\t\t\t\t\t\t\t\t\t] PASSED [ 97%]
|
||||||
|
tests/test_users.py::test_whitespace_only_password_is_rejected[ \n \n \n \n \n \n] PASSED [ 98%]
|
||||||
|
tests/test_users.py::test_nul_in_user_fields_is_rejected[display_name] PASSED [ 99%]
|
||||||
|
tests/test_users.py::test_nul_in_user_fields_is_rejected[password] PASSED [100%]
|
||||||
|
============================= 121 passed in 39.60s =============================
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
== before
|
== before
|
||||||
SERVICE STATUS
|
SERVICE STATUS
|
||||||
api Up 43 seconds (healthy)
|
api Up 44 seconds (healthy)
|
||||||
postgres Up 51 seconds (healthy)
|
postgres Up 52 seconds (healthy)
|
||||||
redis Up 3 seconds (health: starting)
|
redis Up 4 seconds (health: starting)
|
||||||
|
|
||||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||||
@@ -11,4 +11,4 @@ PASS: persistence preserved confirmed data and existing session. Hook scope need
|
|||||||
SERVICE STATUS
|
SERVICE STATUS
|
||||||
api Up 5 seconds (healthy)
|
api Up 5 seconds (healthy)
|
||||||
postgres Up 12 seconds (healthy)
|
postgres Up 12 seconds (healthy)
|
||||||
redis Up 14 seconds (healthy)
|
redis Up 15 seconds (healthy)
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ WHERE chat_id = :chat_id
|
|||||||
ORDER BY created_at, id
|
ORDER BY created_at, id
|
||||||
LIMIT :page
|
LIMIT :page
|
||||||
|
|
||||||
Limit (actual time=0.006..0.015 rows=51 loops=1)
|
Limit (actual time=0.006..0.014 rows=51 loops=1)
|
||||||
Buffers: shared hit=4
|
Buffers: shared hit=4
|
||||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (actual time=0.006..0.012 rows=51 loops=1)
|
-> Index Scan using ix_messages_chat_id_created_at_id on messages (actual time=0.005..0.011 rows=51 loops=1)
|
||||||
Index Cond: (chat_id = '87629e85-f573-467a-b369-74d67ea5f2ac'::uuid)
|
Index Cond: (chat_id = '5355155b-ec73-4a3a-ac44-2417871c9ddf'::uuid)
|
||||||
Buffers: shared hit=4
|
Buffers: shared hit=4
|
||||||
Planning:
|
Planning:
|
||||||
Buffers: shared hit=6
|
Buffers: shared hit=6
|
||||||
Planning Time: 0.051 ms
|
Planning Time: 0.046 ms
|
||||||
Execution Time: 0.025 ms
|
Execution Time: 0.022 ms
|
||||||
|
|
||||||
== page after cursor in the middle of history
|
== page after cursor in the middle of history
|
||||||
SELECT * FROM messages
|
SELECT * FROM messages
|
||||||
@@ -22,13 +22,13 @@ WHERE chat_id = :chat_id AND (created_at, id) > (:after_created_at, :after_id)
|
|||||||
ORDER BY created_at, id
|
ORDER BY created_at, id
|
||||||
LIMIT :page
|
LIMIT :page
|
||||||
|
|
||||||
Limit (actual time=0.007..0.023 rows=51 loops=1)
|
Limit (actual time=0.006..0.018 rows=51 loops=1)
|
||||||
Buffers: shared hit=6
|
Buffers: shared hit=6
|
||||||
-> Index Scan using ix_messages_chat_id_created_at_id on messages (actual time=0.007..0.020 rows=51 loops=1)
|
-> Index Scan using ix_messages_chat_id_created_at_id on messages (actual time=0.006..0.015 rows=51 loops=1)
|
||||||
Index Cond: ((chat_id = '87629e85-f573-467a-b369-74d67ea5f2ac'::uuid) AND (ROW(created_at, id) > ROW('2026-10-26 19:33:40.369572+00'::timestamp with time zone, '540382ff-297f-48c1-8515-aca3063b8347'::uuid)))
|
Index Cond: ((chat_id = '5355155b-ec73-4a3a-ac44-2417871c9ddf'::uuid) AND (ROW(created_at, id) > ROW('2026-10-28 16:00:20.004077+00'::timestamp with time zone, 'c9e332b5-5dd0-4279-a4dd-bf2e1451cc69'::uuid)))
|
||||||
Buffers: shared hit=6
|
Buffers: shared hit=6
|
||||||
Planning Time: 0.044 ms
|
Planning Time: 0.037 ms
|
||||||
Execution Time: 0.046 ms
|
Execution Time: 0.040 ms
|
||||||
|
|
||||||
== same page with index scans disabled (for comparison)
|
== same page with index scans disabled (for comparison)
|
||||||
SELECT * FROM messages
|
SELECT * FROM messages
|
||||||
@@ -36,16 +36,16 @@ WHERE chat_id = :chat_id AND (created_at, id) > (:after_created_at, :after_id)
|
|||||||
ORDER BY created_at, id
|
ORDER BY created_at, id
|
||||||
LIMIT :page
|
LIMIT :page
|
||||||
|
|
||||||
Limit (actual time=4.477..4.483 rows=51 loops=1)
|
Limit (actual time=4.010..4.015 rows=51 loops=1)
|
||||||
Buffers: shared hit=618
|
Buffers: shared hit=618
|
||||||
-> Sort (actual time=4.476..4.479 rows=51 loops=1)
|
-> Sort (actual time=4.009..4.011 rows=51 loops=1)
|
||||||
Sort Key: created_at, id
|
Sort Key: created_at, id
|
||||||
Sort Method: top-N heapsort Memory: 31kB
|
Sort Method: top-N heapsort Memory: 31kB
|
||||||
Buffers: shared hit=618
|
Buffers: shared hit=618
|
||||||
-> Seq Scan on messages (actual time=0.417..4.025 rows=4999 loops=1)
|
-> Seq Scan on messages (actual time=0.379..3.601 rows=4999 loops=1)
|
||||||
Filter: ((chat_id = '87629e85-f573-467a-b369-74d67ea5f2ac'::uuid) AND (ROW(created_at, id) > ROW('2026-10-26 19:33:40.369572+00'::timestamp with time zone, '540382ff-297f-48c1-8515-aca3063b8347'::uuid)))
|
Filter: ((chat_id = '5355155b-ec73-4a3a-ac44-2417871c9ddf'::uuid) AND (ROW(created_at, id) > ROW('2026-10-28 16:00:20.004077+00'::timestamp with time zone, 'c9e332b5-5dd0-4279-a4dd-bf2e1451cc69'::uuid)))
|
||||||
Rows Removed by Filter: 45004
|
Rows Removed by Filter: 45004
|
||||||
Buffers: shared hit=618
|
Buffers: shared hit=618
|
||||||
Planning Time: 0.038 ms
|
Planning Time: 0.036 ms
|
||||||
Execution Time: 4.496 ms
|
Execution Time: 4.024 ms
|
||||||
|
|
||||||
|
|||||||
+14
-14
@@ -1,23 +1,23 @@
|
|||||||
== baseline
|
== baseline
|
||||||
GET /users/me (Bearer) -> 200 (0.003616s)
|
GET /users/me (Bearer) -> 200 (0.003584s)
|
||||||
|
|
||||||
== redis stopped
|
== redis stopped
|
||||||
GET /users/me (Bearer) -> 503 (1.030640s)
|
GET /users/me (Bearer) -> 503 (1.007046s)
|
||||||
POST /auth/sessions (Basic) -> 503 (0.677546s)
|
POST /auth/sessions (Basic) -> 503 (0.659252s)
|
||||||
GET /users/me (no token) -> 401 (0.001655s)
|
GET /users/me (no token) -> 401 (0.001931s)
|
||||||
GET /health/ready -> 503 (0.010732s)
|
GET /health/ready -> 503 (0.010165s)
|
||||||
GET /health/live -> 200 (0.001545s)
|
GET /health/live -> 200 (0.001443s)
|
||||||
-- redis started again (AOF restored)
|
-- redis started again (AOF restored)
|
||||||
GET /users/me (same token) -> 200 (0.004750s)
|
GET /users/me (same token) -> 200 (0.006832s)
|
||||||
|
|
||||||
== postgres stopped
|
== postgres stopped
|
||||||
GET /users/me (Bearer) -> 503 (0.403928s)
|
GET /users/me (Bearer) -> 503 (3.011346s)
|
||||||
GET /api/v1/chats (Bearer) -> 503 (0.011329s)
|
GET /api/v1/chats (Bearer) -> 503 (3.006857s)
|
||||||
GET /health/ready -> 503 (0.170920s)
|
GET /health/ready -> 503 (1.005380s)
|
||||||
GET /health/live -> 200 (0.004790s)
|
GET /health/live -> 200 (0.003165s)
|
||||||
-- postgres started again
|
-- postgres started again
|
||||||
GET /users/me (same token) -> 200 (0.010434s)
|
GET /users/me (same token) -> 200 (0.016088s)
|
||||||
|
|
||||||
== logout
|
== logout
|
||||||
DELETE /auth/sessions/current -> 204 (0.012516s)
|
DELETE /auth/sessions/current -> 204 (0.015784s)
|
||||||
GET /users/me (same token) -> 401 (0.002182s)
|
GET /users/me (same token) -> 401 (0.002551s)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
NAME CPU % MEM USAGE / LIMIT
|
NAME CPU % MEM USAGE / LIMIT
|
||||||
mtusi2026lab2-fork-test-api-1 94.22% 73.3MiB / 15.27GiB
|
mtusi2026lab2-fork-test-api-1 95.15% 70.75MiB / 15.27GiB
|
||||||
mtusi2026lab2-fork-test-postgres-1 17.48% 40.43MiB / 15.27GiB
|
mtusi2026lab2-fork-test-postgres-1 16.41% 39.45MiB / 15.27GiB
|
||||||
mtusi2026lab2-fork-test-redis-1 0.95% 10.62MiB / 15.27GiB
|
mtusi2026lab2-fork-test-redis-1 0.91% 8.484MiB / 15.27GiB
|
||||||
|
|||||||
@@ -2,16 +2,16 @@
|
|||||||
"lab": 2,
|
"lab": 2,
|
||||||
"workload": "closed-loop POST messages; no automatic retries",
|
"workload": "closed-loop POST messages; no automatic retries",
|
||||||
"requested_duration_seconds": 20.0,
|
"requested_duration_seconds": 20.0,
|
||||||
"elapsed_seconds": 20.059,
|
"elapsed_seconds": 20.054,
|
||||||
"concurrency": 8,
|
"concurrency": 8,
|
||||||
"successful_requests": 3050,
|
"successful_requests": 3100,
|
||||||
"failed_requests": 0,
|
"failed_requests": 0,
|
||||||
"error_ratio": 0.0,
|
"error_ratio": 0.0,
|
||||||
"successful_rps": 152.049,
|
"successful_rps": 154.585,
|
||||||
"successful_latency_ms": {
|
"successful_latency_ms": {
|
||||||
"p50": 41.84,
|
"p50": 38.714,
|
||||||
"p95": 128.928,
|
"p95": 130.208,
|
||||||
"p99": 185.164
|
"p99": 196.115
|
||||||
},
|
},
|
||||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
SESSION_TTL_SECONDS=3, login at 20:58:36Z, expires_at=2026-10-26T20:58:39.512095Z
|
SESSION_TTL_SECONDS=3, login at 17:24:28Z, expires_at=2026-10-28T17:24:31.093992Z
|
||||||
GET /users/me right after login -> 200
|
GET /users/me right after login -> 200
|
||||||
GET /users/me after 4 s -> 401
|
GET /users/me after 4 s -> 401
|
||||||
DELETE /auth/sessions/current after -> 401
|
DELETE /auth/sessions/current after -> 401
|
||||||
|
|||||||
@@ -263,3 +263,36 @@ async def test_unknown_user_takes_comparable_time_to_wrong_password(
|
|||||||
unknown_user = await measure("no_such_user")
|
unknown_user = await measure("no_such_user")
|
||||||
|
|
||||||
assert unknown_user > wrong_password * 0.5
|
assert unknown_user > wrong_password * 0.5
|
||||||
|
|
||||||
|
|
||||||
|
async def test_invalid_basic_username_returns_401_not_500(client: AsyncClient):
|
||||||
|
user = await register(client)
|
||||||
|
reference = await client.post(
|
||||||
|
"/api/v1/auth/sessions",
|
||||||
|
headers=basic_header(user["username"], "wrong-password-123"),
|
||||||
|
)
|
||||||
|
|
||||||
|
for username in ("bad\u0000name", "UPPER", "no", "x" * 33, "имя", "a b c"):
|
||||||
|
response = await client.post(
|
||||||
|
"/api/v1/auth/sessions",
|
||||||
|
headers=basic_header(username, "wrong-password-123"),
|
||||||
|
)
|
||||||
|
assert response.status_code == 401, username
|
||||||
|
assert (
|
||||||
|
response.json()["error"]["message"] == reference.json()["error"]["message"]
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
response.headers["WWW-Authenticate"]
|
||||||
|
== reference.headers["WWW-Authenticate"]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_whitespace_only_password_at_login_returns_401(client: AsyncClient):
|
||||||
|
user = await register(client)
|
||||||
|
|
||||||
|
response = await client.post(
|
||||||
|
"/api/v1/auth/sessions", headers=basic_header(user["username"], " " * 12)
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 401
|
||||||
|
assert response.headers["WWW-Authenticate"].startswith("Basic")
|
||||||
|
|||||||
@@ -194,3 +194,16 @@ async def test_chat_endpoints_require_bearer(client: AsyncClient):
|
|||||||
assert (
|
assert (
|
||||||
await client.post("/api/v1/chats", json={"title": "x", "member_ids": []})
|
await client.post("/api/v1/chats", json={"title": "x", "member_ids": []})
|
||||||
).status_code in (401, 400)
|
).status_code in (401, 400)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_nul_in_chat_title_is_rejected(client: AsyncClient):
|
||||||
|
alice = await create_user(client)
|
||||||
|
|
||||||
|
response = await client.post(
|
||||||
|
"/api/v1/chats",
|
||||||
|
headers=bearer(alice),
|
||||||
|
json={"title": "chat\u0000title", "member_ids": [alice["id"]]},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json()["error"]["code"] == "invalid_request"
|
||||||
|
|||||||
@@ -225,3 +225,13 @@ async def test_history_order_is_created_at_then_id(client: AsyncClient):
|
|||||||
assert [m["id"] for m in listed] == [m["id"] for m in created]
|
assert [m["id"] for m in listed] == [m["id"] for m in created]
|
||||||
keys = [(m["created_at"], m["id"]) for m in listed]
|
keys = [(m["created_at"], m["id"]) for m in listed]
|
||||||
assert keys == sorted(keys)
|
assert keys == sorted(keys)
|
||||||
|
|
||||||
|
|
||||||
|
async def test_nul_in_message_text_is_rejected(client: AsyncClient):
|
||||||
|
alice = await create_user(client)
|
||||||
|
chat = await create_chat(client, alice)
|
||||||
|
|
||||||
|
response = await _message(client, alice, chat, "hello\u0000world")
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json()["error"]["code"] == "invalid_request"
|
||||||
|
|||||||
+26
-1
@@ -52,7 +52,9 @@ async def test_invalid_user_payloads(client: AsyncClient, body: dict):
|
|||||||
|
|
||||||
|
|
||||||
async def test_password_length_boundaries_are_accepted(client: AsyncClient):
|
async def test_password_length_boundaries_are_accepted(client: AsyncClient):
|
||||||
for index, password in enumerate(["x" * 12, "y" * 128, " " * 12, "п" * 12]):
|
for index, password in enumerate(
|
||||||
|
["x" * 12, "y" * 128, "п" * 12, " spaces inside "]
|
||||||
|
):
|
||||||
response = await client.post(
|
response = await client.post(
|
||||||
"/api/v1/users",
|
"/api/v1/users",
|
||||||
json={
|
json={
|
||||||
@@ -101,3 +103,26 @@ async def test_user_exact_length_boundaries_are_accepted(client: AsyncClient):
|
|||||||
user = await register(client, username=("a" * length), display_name="d" * 100)
|
user = await register(client, username=("a" * length), display_name="d" * 100)
|
||||||
assert len(user["username"]) == length
|
assert len(user["username"]) == length
|
||||||
assert len(user["display_name"]) == 100
|
assert len(user["display_name"]) == 100
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("password", [" " * 12, "\t" * 12, " \n" * 6])
|
||||||
|
async def test_whitespace_only_password_is_rejected(client: AsyncClient, password: str):
|
||||||
|
response = await client.post(
|
||||||
|
"/api/v1/users",
|
||||||
|
json={"username": "blank_pw", "display_name": "Blank", "password": password},
|
||||||
|
)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json()["error"]["code"] == "invalid_request"
|
||||||
|
assert_request_id(response)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("field", ["display_name", "password"])
|
||||||
|
async def test_nul_in_user_fields_is_rejected(client: AsyncClient, field: str):
|
||||||
|
body = {"username": "nul_user", "display_name": "Nul", "password": PASSWORD}
|
||||||
|
body[field] = body[field] + "\u0000tail"
|
||||||
|
|
||||||
|
response = await client.post("/api/v1/users", json=body)
|
||||||
|
|
||||||
|
assert response.status_code == 400
|
||||||
|
assert response.json()["error"]["code"] == "invalid_request"
|
||||||
|
|||||||
Reference in New Issue
Block a user