forked from mtusi2026/mtusi2026lab7
wip: apply pki-ingress-mtls groups 1-4
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
`Settings` только из аргументов: настоящий читает `.env` и `config.toml`.
|
||||
"""
|
||||
|
||||
import re
|
||||
import socket
|
||||
from typing import Any
|
||||
|
||||
import pytest
|
||||
@@ -15,7 +17,15 @@ from pydantic_settings import (
|
||||
TomlConfigSettingsSource,
|
||||
)
|
||||
|
||||
from src.config.settings import BASE_DIR, Settings, Telemetry, Uploads, Worker
|
||||
from src.config.settings import (
|
||||
BASE_DIR,
|
||||
ApiTls,
|
||||
App,
|
||||
Settings,
|
||||
Telemetry,
|
||||
Uploads,
|
||||
Worker,
|
||||
)
|
||||
from src.schemas.enums import MetricBucketsEnum
|
||||
from src.utils.constants import (
|
||||
API_STOP_BUDGET_SECONDS,
|
||||
@@ -73,6 +83,42 @@ def test_zero_turns_backlog_limit_off() -> None:
|
||||
assert Uploads().max_unfinished_jobs == 250
|
||||
|
||||
|
||||
def test_instance_id_defaults_to_random_alias() -> None:
|
||||
"""Спек `service-configuration`, «Случайный alias по умолчанию»: 16
|
||||
hex-символов, у каждой загрузки настроек свой, без hostname."""
|
||||
first, second = App().instance_id, App().instance_id
|
||||
assert re.fullmatch(r"[0-9a-f]{16}", first)
|
||||
assert first != second
|
||||
assert first != socket.gethostname()
|
||||
|
||||
|
||||
def test_explicit_instance_id() -> None:
|
||||
assert App(instance_id="api-a").instance_id == "api-a"
|
||||
|
||||
|
||||
def test_wrong_instance_id_names_field() -> None:
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
App(instance_id="api a")
|
||||
assert [error["loc"] for error in caught.value.errors()] == [
|
||||
("instance_id",),
|
||||
]
|
||||
|
||||
|
||||
def test_health_port_must_differ_from_port() -> None:
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
App(port=9000, health_port=9000)
|
||||
assert [error["loc"] for error in caught.value.errors()] == [
|
||||
("health_port",),
|
||||
]
|
||||
assert App().health_port == 8081
|
||||
|
||||
|
||||
def test_api_tls_defaults_require_client_certificate() -> None:
|
||||
tls = ApiTls()
|
||||
assert tls.client_auth is True
|
||||
assert tls.allowed_clients == ["haproxy"]
|
||||
|
||||
|
||||
def test_api_stop_with_telemetry_over_budget_names_field() -> None:
|
||||
"""9 с дренажа + 1 с закрытия SDK — SIGKILL docker (verify W3)."""
|
||||
with pytest.raises(ValidationError) as caught:
|
||||
|
||||
Reference in New Issue
Block a user