python -m unittest discover -s student-tests -p "test_*.py" -v
test_auth_checked_before_access_and_body (test_api.MessengerApiTest.test_auth_checked_before_access_and_body) ... ok
test_bad_cursor_returns_400 (test_api.MessengerApiTest.test_bad_cursor_returns_400) ... ok
test_chat_list_pagination (test_api.MessengerApiTest.test_chat_list_pagination) ... ok
test_chat_membership_rules (test_api.MessengerApiTest.test_chat_membership_rules) ... ok
test_duplicate_username_returns_409 (test_api.MessengerApiTest.test_duplicate_username_returns_409) ... ok
test_empty_blank_and_too_long_messages_return_400 (test_api.MessengerApiTest.test_empty_blank_and_too_long_messages_return_400) ... ok
test_malformed_json_returns_400 (test_api.MessengerApiTest.test_malformed_json_returns_400) ... ok
test_nul_character_is_stored (test_api.MessengerApiTest.test_nul_character_is_stored) ... ok
test_outsider_gets_404_for_foreign_chat (test_api.MessengerApiTest.test_outsider_gets_404_for_foreign_chat) ... ok
test_pagination_walks_several_pages (test_api.MessengerApiTest.test_pagination_walks_several_pages) ... ok
test_unicode_roundtrip (test_api.MessengerApiTest.test_unicode_roundtrip) ... ok
test_wrong_types_and_extra_fields_return_400 (test_api.MessengerApiTest.test_wrong_types_and_extra_fields_return_400) ... ok
test_attachment_rules_without_500 (test_attachments.AttachmentTest.test_attachment_rules_without_500) ... ok
test_broken_scan_becomes_failed_and_cannot_be_attached (test_attachments.AttachmentTest.test_broken_scan_becomes_failed_and_cannot_be_attached) ... ok
test_corrupted_images_are_415 (test_attachments.AttachmentTest.test_corrupted_images_are_415) ... ok
test_dangerous_filenames_are_400 (test_attachments.AttachmentTest.test_dangerous_filenames_are_400) ... ok
test_exact_limits (test_attachments.AttachmentTest.test_exact_limits) ... ok
test_idempotency_with_attachments (test_attachments.AttachmentTest.test_idempotency_with_attachments) ... ok
test_large_real_image_within_limits_is_accepted (test_attachments.AttachmentTest.test_large_real_image_within_limits_is_accepted) ... ok
test_message_with_attachments (test_attachments.AttachmentTest.test_message_with_attachments) ... ok
test_mime_spoofing_is_415 (test_attachments.AttachmentTest.test_mime_spoofing_is_415) ... ok
test_outsider_and_anonymous_cannot_upload (test_attachments.AttachmentTest.test_outsider_and_anonymous_cannot_upload) ... ok
test_pixel_bomb_is_413 (test_attachments.AttachmentTest.test_pixel_bomb_is_413) ... ok
test_png_and_jpeg_roundtrip_for_member (test_attachments.AttachmentTest.test_png_and_jpeg_roundtrip_for_member) ... ok
test_structurally_broken_jpeg_is_415 (test_attachments.AttachmentTest.test_structurally_broken_jpeg_is_415) ... ok
test_too_large_is_413_before_reading (test_attachments.AttachmentTest.test_too_large_is_413_before_reading) ... ok
test_too_large_stream_is_413 (test_attachments.AttachmentTest.test_too_large_stream_is_413) ... ok
test_valid_jpeg_variants_are_accepted (test_attachments.AttachmentTest.test_valid_jpeg_variants_are_accepted) ... ok
test_variants_and_bad_ids (test_attachments.AttachmentTest.test_variants_and_bad_ids) ... ok
test_variants_follow_the_contract (test_attachments.AttachmentTest.test_variants_follow_the_contract) ... ok
test_bearer_required_on_business_endpoints (test_auth.AuthTest.test_bearer_required_on_business_endpoints) ... ok
test_login_returns_opaque_token_with_expiry (test_auth.AuthTest.test_login_returns_opaque_token_with_expiry) ... ok
test_logout_revokes_only_current_session (test_auth.AuthTest.test_logout_revokes_only_current_session) ... ok
test_malformed_basic_returns_401 (test_auth.AuthTest.test_malformed_basic_returns_401) ... ok
test_password_length_rules (test_auth.AuthTest.test_password_length_rules) ... ok
test_password_with_colon_and_unicode (test_auth.AuthTest.test_password_with_colon_and_unicode) ... ok
test_relogin_after_logout (test_auth.AuthTest.test_relogin_after_logout) ... ok
test_user_never_contains_password (test_auth.AuthTest.test_user_never_contains_password) ... ok
test_wrong_password_and_unknown_user_look_the_same (test_auth.AuthTest.test_wrong_password_and_unknown_user_look_the_same) ... ok
test_x_user_id_does_not_change_identity (test_auth.AuthTest.test_x_user_id_does_not_change_identity) ... ok
test_instance_id_on_errors_and_health (test_balancing.BalancingTest.test_instance_id_on_errors_and_health) ... ok
test_logout_applies_on_every_replica (test_balancing.BalancingTest.test_logout_applies_on_every_replica) ... ok
test_one_session_is_served_by_every_replica (test_balancing.BalancingTest.test_one_session_is_served_by_every_replica) ... ok
test_session_cache_is_shared_between_replicas (test_balancing.BalancingTest.test_session_cache_is_shared_between_replicas) ... ok
test_write_on_one_replica_read_on_another (test_balancing.BalancingTest.test_write_on_one_replica_read_on_another) ... ok
test_failed_request_does_not_burn_key (test_idempotency.IdempotencyTest.test_failed_request_does_not_burn_key) ... ok
test_json_formatting_does_not_matter (test_idempotency.IdempotencyTest.test_json_formatting_does_not_matter) ... ok
test_key_is_required_and_validated (test_idempotency.IdempotencyTest.test_key_is_required_and_validated) ... ok
test_key_scope_is_user_and_chat (test_idempotency.IdempotencyTest.test_key_scope_is_user_and_chat) ... ok
test_parallel_different_bodies_same_key (test_idempotency.IdempotencyTest.test_parallel_different_bodies_same_key) ... ok
test_parallel_same_key_through_replicas_creates_one_message (test_idempotency.IdempotencyTest.test_parallel_same_key_through_replicas_creates_one_message) ... ok
test_replay_rechecks_session_and_access (test_idempotency.IdempotencyTest.test_replay_rechecks_session_and_access) ... ok
test_replay_through_another_replica_returns_same_message (test_idempotency.IdempotencyTest.test_replay_through_another_replica_returns_same_message) ... ok
test_same_key_other_body_is_409 (test_idempotency.IdempotencyTest.test_same_key_other_body_is_409) ... ok
test_big_body_rejected_before_authentication (test_limits.LimitsTest.test_big_body_rejected_before_authentication) ... ok
test_body_over_limit_chunked_is_413 (test_limits.LimitsTest.test_body_over_limit_chunked_is_413) ... ok
test_body_over_limit_with_content_length_is_413 (test_limits.LimitsTest.test_body_over_limit_with_content_length_is_413) ... ok
test_body_under_limit_is_accepted (test_limits.LimitsTest.test_body_under_limit_is_accepted) ... ok
test_limit_is_per_username (test_limits.LimitsTest.test_limit_is_per_username) ... ok
test_login_failures_lead_to_429_with_retry_after_across_replicas (test_limits.LimitsTest.test_login_failures_lead_to_429_with_retry_after_across_replicas) ... ok
test_old_hash_is_rehashed_on_login (test_limits.LimitsTest.test_old_hash_is_rehashed_on_login) ... ok
test_success_resets_failure_counter (test_limits.LimitsTest.test_success_resets_failure_counter) ... ok
test_wrong_password_does_not_rehash (test_limits.LimitsTest.test_wrong_password_does_not_rehash) ... ok

----------------------------------------------------------------------
Ran 63 tests in 55.072s

OK

  10 485 760 байт и 6400×6250 = 40 000 000 px: 202 -> ready; на 1 байт/пиксель больше: 413

  fixture 320×200 -> thumbnail 256×160 JPEG, crop 128×128 JPEG, optimized 320×200 WebP; 48×32 -> {'thumbnail': (48, 32), 'crop': (128, 128), 'optimized': (48, 32)}

  X-Instance-Id есть в health, 404, 401 и 400

  logout через одну реплику -> 401 на ['r-4265d3e11ef7', 'r-d2dbb84b8d7b']

  20 x GET /users/me с одним токеном -> реплики {'r-d2dbb84b8d7b': 10, 'r-4265d3e11ef7': 10}; это alias запущенных реплик api (с lab7 — случайные, не hostname), повторный вход не нужен

  10 x GET /users/me через реплики {'r-d2dbb84b8d7b': 5, 'r-4265d3e11ef7': 5}: попаданий в кэш +20, промахов +0 — кэш общий

  сообщение записала реплика r-d2dbb84b8d7b, сразу прочитали ['r-4265d3e11ef7', 'r-d2dbb84b8d7b']

  с тем же ключом: сначала 400 (пустой текст), потом 201 — ошибка ключ не заняла

  тот же JSON с другими пробелами и переносами -> тот же 201 и то же сообщение

  нет ключа, пустой, 129 символов, пробел, '/', кириллица -> 400; 128 символов и ._:- -> 201

  тот же ключ у другого пользователя и в другом чате -> независимые сообщения

  10 одновременных разных тел с одним ключом: 201 x1, 409 x9, в истории 1 сообщение

  20 одновременных POST с одним ключом через реплики {'r-4265d3e11ef7': 10, 'r-d2dbb84b8d7b': 10}: все 201 с одним id, в истории 1 сообщение

  повтор: посторонний -> 404, после logout -> 401, после нового входа -> то же сообщение

  1 запрос + 4 повтора через реплики ['r-4265d3e11ef7', 'r-d2dbb84b8d7b']: 201 и то же сообщение, в истории 1

  другой текст с тем же ключом -> 409 conflict, второе сообщение не создано

  POST /users, chunked 66643 bytes without Content-Length -> 413 payload_too_large

  POST /users, Content-Length 66643 -> 413 payload_too_large

  10 wrong passwords -> 401, served by 2 of 2 replicas
  next login (even with the right password) -> 429 rate_limited, Retry-After: 298 s

  stored hash params: m=8192,t=1,p=1 -> after login m=19456,t=2,p=1
