Исправлены ошибки, выявленные на тесте инфраструктуры

This commit is contained in:
mi
2026-07-15 13:18:30 +03:00
parent 6d1cb3d6d9
commit caf6bf0516
8 changed files with 137 additions and 19 deletions
@@ -228,7 +228,12 @@ class S3Client:
endpoint_url=str(settings.selectel_s3_endpoint_url),
aws_access_key_id=settings.selectel_s3_access_key.get_secret_value(),
aws_secret_access_key=settings.selectel_s3_secret_key.get_secret_value(),
config=Config(connect_timeout=3, read_timeout=10, retries={"max_attempts": 2}),
config=Config(
connect_timeout=3,
read_timeout=10,
retries={"max_attempts": 2},
s3={"addressing_style": "virtual"},
),
)
async def ready(self) -> bool:
@@ -1,4 +1,5 @@
import uuid
from urllib.parse import urlsplit
import httpx
import pytest
@@ -6,6 +7,7 @@ import pytest
from app.integrations import (
DependencyFailure,
OpenLinesClient,
S3Client,
SafetyClient,
fresh_openlines_payload,
)
@@ -39,6 +41,19 @@ def settings() -> Settings:
return Settings.model_validate(common)
@pytest.mark.asyncio
async def test_s3_presigned_urls_use_virtual_hosted_addressing() -> None:
s3 = S3Client(settings())
put_url = await s3.presign_put("quarantine/users/u/file.pdf", "application/pdf", 600)
get_url = await s3.presign_get("attachments", "dialogs/d/file.pdf")
assert urlsplit(put_url).netloc == "quarantine.s3.example"
assert urlsplit(put_url).path == "/quarantine/users/u/file.pdf"
assert urlsplit(get_url).netloc == "attachments.s3.example"
assert urlsplit(get_url).path == "/dialogs/d/file.pdf"
@pytest.mark.asyncio
async def test_safety_contract_status_and_service_token() -> None:
async def handler(request: httpx.Request) -> httpx.Response:
@@ -390,6 +390,11 @@ SELECTEL_S3_QUARANTINE_READ_ACCESS_KEY=<SAFETY_READ_ACCESS_KEY>
SELECTEL_S3_QUARANTINE_READ_SECRET_KEY=<SAFETY_READ_SECRET_KEY>
```
API backend принудительно использует virtual-hosted addressing:
`https://<bucket>.s3.storage.selcloud.ru/<object-key>`. Это обязательно для
браузерных presigned PUT и CORS в Selectel; path-style URL для этого сценария не
используйте. DNS и исходящий HTTPS с ВМ должны разрешать поддомены бакетов.
### 8.7. Bitrix24
До установки локального приложения заполните: