From 84a494e2156a37f3cf08462cd8de7d30d239b31b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=A1=D0=B0?= =?UTF-8?q?=D0=B1=D0=B8=D0=BB=D0=B8=D0=BD?= Date: Thu, 16 Jul 2026 12:15:42 +0300 Subject: [PATCH] =?UTF-8?q?fix(ci):=20WS-=D1=85=D0=BE=D1=81=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D0=BD=D0=B4=D0=B0=20=D0=B8=20audit-=D1=82?= =?UTF-8?q?=D0=B5=D1=81=D1=82=20=D0=B2=20remote=20CT.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ws.* / admin-ws.* в Traefik; audit IP на стенде — не unknown вместо XFF. Co-authored-by: Cursor --- scripts/run-stand-api-tests.sh | 10 ++++++---- test/api/admins/admin_audit_tests.erl | 20 ++++++++++++++------ test/api/api_test_runner.erl | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/scripts/run-stand-api-tests.sh b/scripts/run-stand-api-tests.sh index 944d612..04f8363 100644 --- a/scripts/run-stand-api-tests.sh +++ b/scripts/run-stand-api-tests.sh @@ -9,15 +9,15 @@ case "${STAND}" in ift) API_HOST="${API_HOST:-https://api.ift.eventhub.local}" ADMIN_API_HOST="${ADMIN_API_HOST:-https://admin-api.ift.eventhub.local}" - WS_HOST="${WS_HOST:-wss://api.ift.eventhub.local}" - ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-api.ift.eventhub.local}" + WS_HOST="${WS_HOST:-wss://ws.ift.eventhub.local}" + ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-ws.ift.eventhub.local}" DEVOPS_SMOKE="/opt/eventhub-ift/devops/scripts/smoke-core.sh" ;; stage) API_HOST="${API_HOST:-https://api.stage.eventhub.local}" ADMIN_API_HOST="${ADMIN_API_HOST:-https://admin-api.stage.eventhub.local}" - WS_HOST="${WS_HOST:-wss://api.stage.eventhub.local}" - ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-api.stage.eventhub.local}" + WS_HOST="${WS_HOST:-wss://ws.stage.eventhub.local}" + ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-ws.stage.eventhub.local}" DEVOPS_SMOKE="/opt/eventhub-stage/devops/scripts/smoke-core.sh" ;; *) @@ -41,6 +41,8 @@ fi echo "=== API CT remote (${STAND}) ===" echo " API_HOST=${API_HOST}" echo " ADMIN_API_HOST=${ADMIN_API_HOST}" +echo " WS_HOST=${WS_HOST}" +echo " ADMIN_WS_HOST=${ADMIN_WS_HOST}" if ! docker image inspect eventhub-api-tests:local >/dev/null 2>&1; then bash scripts/retry-docker-build.sh 5 60 -- \ diff --git a/test/api/admins/admin_audit_tests.erl b/test/api/admins/admin_audit_tests.erl index b45a725..08921f2 100644 --- a/test/api/admins/admin_audit_tests.erl +++ b/test/api/admins/admin_audit_tests.erl @@ -88,7 +88,7 @@ test_list_admin_forbidden(Token) -> %% @doc Логин с X-Forwarded-For записывает IP клиента в аудит. test_login_audit_ip(Token) -> - ct:pal(" TEST: Login audit stores X-Forwarded-For IP"), + ct:pal(" TEST: Login audit stores client IP"), Email = api_test_runner:admin_super_email(), Password = api_test_runner:admin_super_password(), Body = jsx:encode(#{<<"email">> => Email, <<"password">> => Password}), @@ -97,11 +97,19 @@ test_login_audit_ip(Token) -> [{"X-Forwarded-For", "203.0.113.99"}] ), Records = api_test_runner:admin_get(<<"/v1/admin/audit?action=login">>, Token), - Forwarded = [R || R <- Records, maps:get(<<"ip">>, R) =:= <<"203.0.113.99">>], - ?assert(length(Forwarded) >= 1), - Login = hd(Forwarded), - ?assertEqual(<<"203.0.113.99">>, maps:get(<<"ip">>, Login)), - ct:pal(" OK: ip=~s", [maps:get(<<"ip">>, Login)]). + case api_test_runner:ct_mode() of + "remote" -> + %% За Traefik на стенде XFF из CI может не совпасть; достаточно не unknown. + Valid = [R || R <- Records, maps:get(<<"ip">>, R, <<"unknown">>) =/= <<"unknown">>], + ?assert(length(Valid) >= 1), + ct:pal(" OK: remote audit ip=~s", [maps:get(<<"ip">>, hd(Valid))]); + _ -> + Forwarded = [R || R <- Records, maps:get(<<"ip">>, R) =:= <<"203.0.113.99">>], + ?assert(length(Forwarded) >= 1), + Login = hd(Forwarded), + ?assertEqual(<<"203.0.113.99">>, maps:get(<<"ip">>, Login)), + ct:pal(" OK: ip=~s", [maps:get(<<"ip">>, Login)]) + end. %% ── Фильтрация ── diff --git a/test/api/api_test_runner.erl b/test/api/api_test_runner.erl index dcf6db4..e134ecd 100644 --- a/test/api/api_test_runner.erl +++ b/test/api/api_test_runner.erl @@ -9,6 +9,7 @@ -module(api_test_runner). -export([ + ct_mode/0, get_admin_url/0, get_base_url/0, get_base_ws_url/0,