lab7: тесты безопасности и перевод своих тестов на HTTPS, документы (trust-matrix, THREAT_MODEL, OPERATOR, DEFENSE, WINDOWS, PR), сборщик доказательств, чистка legacy bench

This commit is contained in:
Alexey Bodanyuk
2026-11-27 17:43:14 +03:00
parent 05df1695fe
commit 84dbdb4735
44 changed files with 1644 additions and 2686 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ from pathlib import Path
import pytest
import imagegen
from conftest import api_with_env, attachment_row, psql, s3_size
from conftest import TLS, api_with_env, attachment_row, psql, s3_size
pytestmark = pytest.mark.stack
@@ -52,7 +52,7 @@ def wait_for(condition, timeout: float, what: str) -> None:
def raw_upload(token: str, chat_id: str, declared: int, body: bytes, *, wait_answer: float | None) -> bytes:
"""Hand-made HTTP request: announce `declared` bytes, send only `body`, then either close the
socket (client gone) or keep it open and read the answer after `wait_answer` seconds."""
sock = socket.create_connection(("127.0.0.1", 8080), timeout=30)
sock = TLS.wrap_socket(socket.create_connection(("127.0.0.1", 8443), timeout=30), server_hostname="localhost")
head = (f"POST /api/v1/chats/{chat_id}/attachments?filename=x.png HTTP/1.1\r\nHost: localhost\r\n"
f"Authorization: Bearer {token}\r\nContent-Type: image/png\r\nContent-Length: {declared}\r\n\r\n")
sock.sendall(head.encode() + body)