lab7: тесты безопасности и перевод своих тестов на HTTPS, документы (trust-matrix, THREAT_MODEL, OPERATOR, DEFENSE, WINDOWS, PR), сборщик доказательств, чистка legacy bench
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user