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:
@@ -2,6 +2,7 @@
|
||||
форматы."""
|
||||
|
||||
import json
|
||||
import re
|
||||
import urllib.parse
|
||||
import uuid
|
||||
from collections import Counter
|
||||
@@ -35,6 +36,8 @@ UNICODE_TEXT = "Привет, мир 👋"
|
||||
NOT_UUID_PATHS = ("123", "false", "[]", "{}")
|
||||
# не UUID в элементе member_ids: значения других типов JSON
|
||||
NOT_UUID_VALUES: tuple[Any, ...] = ([], {}, 123, False)
|
||||
# alias процесса по умолчанию (с лабы 7): secrets.token_hex(8)
|
||||
ALIAS_PATTERN = re.compile(r"[0-9a-f]{16}")
|
||||
|
||||
|
||||
@pytest.mark.spec("api-conventions", "Unicode сохраняется")
|
||||
@@ -176,6 +179,26 @@ def test_one_instance_id_per_process(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.spec("api-conventions", "Instance id — случайный alias")
|
||||
def test_instance_id_is_random_alias(
|
||||
api: Api,
|
||||
alice: Actor,
|
||||
eve: Actor,
|
||||
chat: dict[str, Any],
|
||||
) -> None:
|
||||
"""С лабы 7 значение по умолчанию — 16 hex-символов alias процесса, а
|
||||
не hostname контейнера compose (12 символов его ID) и не IP: успехи,
|
||||
ошибки и health напрямую или через LB."""
|
||||
responses = business_responses(api, alice, eve, chat)
|
||||
responses += service_responses(api)
|
||||
for resp, status in responses:
|
||||
assert resp.status_code == status, resp.text
|
||||
value = assert_instance_id(resp)
|
||||
assert ALIAS_PATTERN.fullmatch(value), (
|
||||
f"X-Instance-Id {value!r} is not a 16 hex character alias"
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.spec("api-conventions", "Ошибка содержит request_id заголовка")
|
||||
def test_error_request_id_matches_header(
|
||||
api: Api,
|
||||
|
||||
Reference in New Issue
Block a user