== 03: собственные проверки (student-tests) ==
date: 2026-10-23T19:19:36Z (UTC)
host: Windows 10 Pro 19045, Git Bash (MSYS), python3 3.11.9; стенд поднят docker compose

Что показывает: проверки поверх публичного контракта — пароли и границы их длины,
сессии и их отзыв, доступ к чужим чатам, атомарность создания чата, гонка регистрации,
пагинация, валидация и живучесть при недоступной зависимости. Три проверки
отказоустойчивости пропущены: они останавливают контейнеры и запускаются отдельно
с ALLOW_OUTAGE=1 (доказательства 05 и 06).

Адрес стенда — 127.0.0.1, а не localhost: на Windows имя localhost разрешается сначала
в ::1, и обращение к опубликованному порту 127.0.0.1:8080 добавляло бы около двух секунд
на запрос. Стенд публикует только loopback, так что это тот же самый адрес.

PYTHON="python3 -X utf8" передан аргументом make: этой сборке make переменные
окружения не передаются, а вывод тестов на русском в консоли Windows иначе
попал бы в файл в кодировке cp1251.

$ make student-test BASE_URL=http://127.0.0.1:8080 PYTHON="python3 -X utf8"
python3 -X utf8 student-tests/run_all.py --base-url "http://127.0.0.1:8080"
BASE_URL = http://127.0.0.1:8080
test_a_foreign_chat_and_a_missing_chat_are_reported_alike (test_access.ChatVisibility.test_a_foreign_chat_and_a_missing_chat_are_reported_alike)
Тот же статус, тот же код, то же сообщение: разница не должна утекать. ... ok
test_a_left_member_still_sees_the_history (test_access.ChatVisibility.test_a_left_member_still_sees_the_history)
Участие фиксируется при создании, поэтому история участника не исчезает. ... ok
test_members_read_the_chat (test_access.ChatVisibility.test_members_read_the_chat) ... ok
test_outsider_cannot_write (test_access.ChatVisibility.test_outsider_cannot_write) ... ok
test_outsider_does_not_see_the_chat_in_the_list (test_access.ChatVisibility.test_outsider_does_not_see_the_chat_in_the_list) ... ok
test_outsider_gets_not_found (test_access.ChatVisibility.test_outsider_gets_not_found) ... ok
test_x_user_id_does_not_open_a_foreign_chat (test_access.ChatVisibility.test_x_user_id_does_not_open_a_foreign_chat) ... ok
test_each_session_sees_its_own_user (test_access.CurrentUser.test_each_session_sees_its_own_user) ... ok
test_registration_body_is_never_echoed (test_access.CurrentUser.test_registration_body_is_never_echoed) ... ok
test_basic_is_accepted_on_the_session_route (test_auth.Credentials.test_basic_is_accepted_on_the_session_route) ... ok
test_basic_is_rejected_on_business_routes (test_auth.Credentials.test_basic_is_rejected_on_business_routes)
Учётные данные Basic не должны открывать /users/me: челлендж должен требовать Bearer. ... ok
test_bearer_is_rejected_on_the_session_route (test_auth.Credentials.test_bearer_is_rejected_on_the_session_route)
Маршрут входа принимает только Basic; сессионный токен не создаёт сессию. ... ok
test_malformed_authorization_headers (test_auth.Credentials.test_malformed_authorization_headers) ... ok
test_token_is_opaque_and_unique (test_auth.Credentials.test_token_is_opaque_and_unique) ... ok
test_unknown_user_and_wrong_password_are_indistinguishable (test_auth.Credentials.test_unknown_user_and_wrong_password_are_indistinguishable)
Тот же статус, тот же код, то же сообщение — и сопоставимый объём работы. ... ok
test_x_user_id_cannot_authenticate_or_impersonate (test_auth.Credentials.test_x_user_id_cannot_authenticate_or_impersonate)
Заголовок из лабораторной 1 не работает: не даёт доступа и не переопределяет сессию. ... ok
test_accepted_passwords_work_for_login (test_auth.Registration.test_accepted_passwords_work_for_login) ... ok
test_duplicate_username_conflicts (test_auth.Registration.test_duplicate_username_conflicts) ... ok
test_multibyte_password_far_beyond_72_bytes (test_auth.Registration.test_multibyte_password_far_beyond_72_bytes)
128 кириллических кодовых точек — это 256 байт UTF-8, и они проходят без потерь. ... ok
test_password_is_checked_to_the_last_byte (test_auth.Registration.test_password_is_checked_to_the_last_byte)
Пароль длиннее 72 байт не усекается KDF. ... ok
test_password_is_required (test_auth.Registration.test_password_is_required) ... ok
test_password_length_bounds (test_auth.Registration.test_password_length_bounds)
11 и 129 кодовых точек отклоняются; 12 и 128 принимаются. ... ok
test_password_may_contain_a_colon (test_auth.Registration.test_password_may_contain_a_colon)
Basic разделяет только по первому двоеточию, остальное принадлежит паролю. ... ok
test_surrounding_spaces_are_part_of_the_password (test_auth.Registration.test_surrounding_spaces_are_part_of_the_password)
Пароль не обрезается: пробелы по краям значат то же, что и любые другие символы. ... ok
test_whitespace_only_password_is_refused (test_auth.Registration.test_whitespace_only_password_is_refused)
Двенадцать пробелов — пустое значение обязательного поля, а не пароль. ... ok
test_a_valid_chat_is_created_whole (test_chat_atomicity.ChatCreation.test_a_valid_chat_is_created_whole) ... ok
test_creator_must_be_a_member (test_chat_atomicity.ChatCreation.test_creator_must_be_a_member) ... ok
test_duplicate_members_are_refused (test_chat_atomicity.ChatCreation.test_duplicate_members_are_refused) ... ok
test_empty_and_oversized_member_lists_are_refused (test_chat_atomicity.ChatCreation.test_empty_and_oversized_member_lists_are_refused) ... ok
test_one_unknown_member_among_known_ones_still_rolls_back (test_chat_atomicity.ChatCreation.test_one_unknown_member_among_known_ones_still_rolls_back) ... ok
test_unknown_member_is_refused_without_a_trace (test_chat_atomicity.ChatCreation.test_unknown_member_is_refused_without_a_trace) ... ok
test_liveness_stays_green_throughout (test_dependency_outage.DependencyOutage.test_liveness_stays_green_throughout)
Отказ зависимости не должен выглядеть для супервизора смертью процесса. ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
test_postgres_outage (test_dependency_outage.DependencyOutage.test_postgres_outage) ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
test_valkey_outage (test_dependency_outage.DependencyOutage.test_valkey_outage) ... skipped 'задайте ALLOW_OUTAGE=1 для запуска: этот модуль останавливает контейнеры'
    api пересоздан с SESSION_TTL_SECONDS=3, готов через 3.73s
test_a_token_issued_before_the_change_still_works (test_expiry.ShortLivedSessions.test_a_token_issued_before_the_change_still_works)
Пересоздание API не выдаёт новые сессии и не продлевает старые. ...     у токена, выданного до переключения, осталось 3596s из исходных 3600s
ok
test_a_token_stops_working_once_the_ttl_passes (test_expiry.ShortLivedSessions.test_a_token_stops_working_once_the_ttl_passes) ...     через 4s токен отвергается обоими маршрутами, а его ключ исчез
ok
test_expiry_does_not_need_a_cleanup_job (test_expiry.ShortLivedSessions.test_expiry_does_not_need_a_cleanup_job)
Хранилище никто не чистит: ключа просто больше нет. ...     ключ исчез сам между двумя запросами: приложение не удаляет просроченные сессии
ok
test_the_short_ttl_is_the_one_in_force (test_expiry.ShortLivedSessions.test_the_short_ttl_is_the_one_in_force) ...     expires_at через 3.00s, ключ в Valkey живёт 3s: сроком владеет хранилище, а не процесс
ok
    api пересоздан с SESSION_TTL_SECONDS=3600, готов через 3.78s
test_error_envelope_carries_a_request_id (test_health.Probes.test_error_envelope_carries_a_request_id) ... ok
test_every_probe_gets_its_own_request_id (test_health.Probes.test_every_probe_gets_its_own_request_id) ... ok
test_liveness (test_health.Probes.test_liveness) ... ok
test_probes_need_no_credentials (test_health.Probes.test_probes_need_no_credentials) ... ok
test_readiness (test_health.Probes.test_readiness) ... ok
test_readiness_is_not_a_cached_constant (test_health.Probes.test_readiness_is_not_a_cached_constant)
Повторные пробы должен обслуживать процесс, а не кешированное тело. ... ok
test_a_cursor_from_one_user_is_refused_for_another (test_pagination.ChatList.test_a_cursor_from_one_user_is_refused_for_another) ... ok
test_chat_pages_cover_the_list_exactly_once (test_pagination.ChatList.test_chat_pages_cover_the_list_exactly_once) ... ok
test_a_cursor_from_another_chat_is_refused (test_pagination.MessageHistory.test_a_cursor_from_another_chat_is_refused) ... ok
test_a_cursor_from_another_user_is_refused (test_pagination.MessageHistory.test_a_cursor_from_another_user_is_refused) ... ok
test_a_cursor_from_the_chat_list_is_refused_here (test_pagination.MessageHistory.test_a_cursor_from_the_chat_list_is_refused_here) ... ok
test_items_are_ordered_by_created_at_then_id (test_pagination.MessageHistory.test_items_are_ordered_by_created_at_then_id) ... ok
test_pages_cover_the_history_exactly_once (test_pagination.MessageHistory.test_pages_cover_the_history_exactly_once) ... ok
test_small_pages_agree_with_a_single_large_one (test_pagination.MessageHistory.test_small_pages_agree_with_a_single_large_one) ... ok
test_the_second_page_starts_right_after_the_first (test_pagination.MessageHistory.test_the_second_page_starts_right_after_the_first) ... ok
test_database_holds_exactly_one_row (test_registration_race.RegistrationRace.test_database_holds_exactly_one_row) ... ok
test_every_loser_gets_the_conflict_envelope (test_registration_race.RegistrationRace.test_every_loser_gets_the_conflict_envelope) ... ok
test_only_one_registration_wins (test_registration_race.RegistrationRace.test_only_one_registration_wins) ... ok
test_vanishing_key_means_unauthorized (test_sessions.ExpiryIsEnforcedByTheStore.test_vanishing_key_means_unauthorized) ... ok
test_logout_returns_an_empty_204_and_then_401 (test_sessions.Lifecycle.test_logout_returns_an_empty_204_and_then_401) ... ok
test_missing_and_unknown_tokens (test_sessions.Lifecycle.test_missing_and_unknown_tokens) ... ok
test_revocation_closes_every_route (test_sessions.Lifecycle.test_revocation_closes_every_route) ... ok
test_session_matches_the_contract (test_sessions.Lifecycle.test_session_matches_the_contract) ... ok
test_session_survives_an_api_process_restart (test_sessions.Lifecycle.test_session_survives_an_api_process_restart)
Сессии не в памяти процесса: перезапуск только API их сохраняет. ... ok
test_two_sessions_are_independent (test_sessions.Lifecycle.test_two_sessions_are_independent) ... ok
test_revocation_removes_the_key (test_sessions.Storage.test_revocation_removes_the_key) ... ok
test_token_entropy (test_sessions.Storage.test_token_entropy)
16 входов подряд должны дать 16 разных токенов: повтор ломал бы отзыв. ... ok
test_token_is_not_stored_verbatim (test_sessions.Storage.test_token_is_not_stored_verbatim) ... ok
test_empty_cursor_is_refused (test_validation.QueryParameters.test_empty_cursor_is_refused) ... ok
test_invalid_chat_id (test_validation.QueryParameters.test_invalid_chat_id) ... ok
test_limit_bounds (test_validation.QueryParameters.test_limit_bounds) ... ok
test_non_numeric_limit (test_validation.QueryParameters.test_non_numeric_limit) ... ok
test_tampered_cursor_is_refused (test_validation.QueryParameters.test_tampered_cursor_is_refused) ... ok
test_broken_json_is_refused_without_echoing_it (test_validation.RequestBodies.test_broken_json_is_refused_without_echoing_it) ... ok
test_display_name_and_title_limits (test_validation.RequestBodies.test_display_name_and_title_limits) ... ok
test_message_text_limits (test_validation.RequestBodies.test_message_text_limits) ... ok
test_missing_required_fields (test_validation.RequestBodies.test_missing_required_fields) ... ok
test_nul_is_refused_before_it_reaches_the_store (test_validation.RequestBodies.test_nul_is_refused_before_it_reaches_the_store)
U+0000 не хранится в `text`: это 400, а не ложная недоступность базы. ... ok
test_sender_id_cannot_be_injected (test_validation.RequestBodies.test_sender_id_cannot_be_injected) ... ok
test_the_password_never_appears_in_an_error (test_validation.RequestBodies.test_the_password_never_appears_in_an_error) ... ok
test_unknown_json_field_is_refused (test_validation.RequestBodies.test_unknown_json_field_is_refused) ... ok
test_username_pattern (test_validation.RequestBodies.test_username_pattern) ... ok
test_unknown_route (test_validation.Routing.test_unknown_route) ... ok
test_wrong_method (test_validation.Routing.test_wrong_method) ... ok

----------------------------------------------------------------------
Ran 82 tests in 30.188s

OK (skipped=3)
