feat: ЛР4 - S3 хранилище MinIO, загрузка вложений и защита от атак

This commit is contained in:
Ильяс
2026-11-06 15:59:44 +03:00
parent 9b574fa5e9
commit 4979731408
24 changed files with 1418 additions and 72 deletions
+2
View File
@@ -0,0 +1,2 @@
.venv/bin/python scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+7
View File
@@ -0,0 +1,7 @@
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
mtusi2026lab4-api-1-1 highload-messenger:lab4 "python -m uvicorn a…" api-1 6 minutes ago Up About a minute (healthy) 8080/tcp
mtusi2026lab4-api-2-1 highload-messenger:lab4 "python -m uvicorn a…" api-2 6 minutes ago Up 2 minutes (healthy) 8080/tcp
mtusi2026lab4-load_balancer-1 nginx:1.27-alpine "/docker-entrypoint.…" load_balancer 10 minutes ago Up 2 minutes (healthy) 80/tcp, 0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp
mtusi2026lab4-minio-1 cleanstart/minio:latest "/usr/bin/minio serv…" minio 10 minutes ago Up 2 minutes (healthy)
mtusi2026lab4-postgres-1 postgres:16-alpine "docker-entrypoint.s…" postgres 10 minutes ago Up 2 minutes (healthy) 5432/tcp
mtusi2026lab4-redis-1 redis:7-alpine "docker-entrypoint.s…" redis 10 minutes ago Up 2 minutes (healthy) 6379/tcp
+4
View File
@@ -0,0 +1,4 @@
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 123, "failed_attempts": 0, "first_recovery_seconds": 0.768}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 4,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.015,
"concurrency": 4,
"successful_requests": 9286,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 309.375,
"successful_latency_ms": {
"p50": 7.928,
"p95": 40.768,
"p99": 62.963
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+3
View File
@@ -0,0 +1,3 @@
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+10
View File
@@ -0,0 +1,10 @@
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
x-instance-id: api-2
x-instance-id: api-1
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
+45
View File
@@ -0,0 +1,45 @@
============================= test session starts ==============================
platform linux -- Python 3.12.15, pytest-9.1.1, pluggy-1.7.0 -- /home/ilyas/projects/labs_highload/mtusi2026lab4/.venv/bin/python3.12
cachedir: .pytest_cache
rootdir: /home/ilyas/projects/labs_highload/mtusi2026lab4
configfile: pytest.ini
plugins: anyio-4.16.0, asyncio-1.4.0
asyncio: mode=Mode.AUTO, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collecting ... collected 34 items
tests_student/tests.py::test_invalid_json_and_extra_fields PASSED [ 2%]
tests_student/tests.py::test_outsider_chat_access_is_404 PASSED [ 5%]
tests_student/tests.py::test_empty_and_whitespace_message PASSED [ 8%]
tests_student/tests.py::test_duplicate_username_conflict PASSED [ 11%]
tests_student/tests.py::test_wrong_password_and_bad_basic_auth PASSED [ 14%]
tests_student/tests.py::test_logout_and_revocation PASSED [ 17%]
tests_student/tests.py::test_multi_page_cursor_pagination PASSED [ 20%]
tests_student/tests.py::test_concurrency_race_condition PASSED [ 23%]
tests_student/tests.py::test_password_whitespace_rejected PASSED [ 26%]
tests_student/tests.py::test_auth_sessions_with_body_rejected PASSED [ 29%]
tests_student/tests.py::test_unsupported_media_type_415 PASSED [ 32%]
tests_student/tests.py::test_nul_byte_in_strings_handled PASSED [ 35%]
tests_student/tests.py::test_basic_auth_invalid_base64_returns_401 PASSED [ 38%]
tests_student/tests.py::test_cross_chat_cursor_rejected_400 PASSED [ 41%]
tests_student/tests.py::test_utf8_password_support PASSED [ 44%]
tests_student/tests.py::test_health_readiness_and_liveness PASSED [ 47%]
tests_student/tests.py::test_instance_id_header_present PASSED [ 50%]
tests_student/tests.py::test_idempotency_key_validation PASSED [ 52%]
tests_student/tests.py::test_idempotency_replay_and_conflict PASSED [ 55%]
tests_student/tests.py::test_idempotency_acl_check_on_replay PASSED [ 58%]
tests_student/tests.py::test_invalid_cursor_date_returns_400 PASSED [ 61%]
tests_student/tests.py::test_strict_types_and_json_parsing PASSED [ 64%]
tests_student/tests.py::test_chat_creation_with_unknown_participant_is_400 PASSED [ 67%]
tests_student/tests.py::test_password_with_colons_and_utf8 PASSED [ 70%]
tests_student/tests.py::test_keyset_pagination_returns_next_cursor PASSED [ 73%]
tests_student/tests.py::test_attachment_upload_and_download_flow PASSED [ 76%]
tests_student/tests.py::test_attachment_unsupported_media_type_and_magic_bytes PASSED [ 79%]
tests_student/tests.py::test_attachment_filename_validation PASSED [ 82%]
tests_student/tests.py::test_attachment_payload_too_large_and_pixel_bomb PASSED [ 85%]
tests_student/tests.py::test_attachment_acl_and_isolation PASSED [ 88%]
tests_student/tests.py::test_message_linking_attachments PASSED [ 91%]
tests_student/tests.py::test_attachment_orphan_compensation PASSED [ 94%]
tests_student/tests.py::test_private_bucket_outside_api PASSED [ 97%]
tests_student/tests.py::test_concurrent_uploads_memory_limit PASSED [100%]
============================= 34 passed in 37.86s ==============================
+2
View File
@@ -0,0 +1,2 @@
.venv/bin/python scripts/validate_openapi.py
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.