fix(ci): WS-хосты стенда и audit-тест в remote CT.
CI / test (push) Successful in 15m59s

ws.* / admin-ws.* в Traefik; audit IP на стенде — не unknown вместо XFF.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-16 12:15:42 +03:00
parent 50c6d671b8
commit 84a494e215
3 changed files with 21 additions and 10 deletions
+6 -4
View File
@@ -9,15 +9,15 @@ case "${STAND}" in
ift) ift)
API_HOST="${API_HOST:-https://api.ift.eventhub.local}" API_HOST="${API_HOST:-https://api.ift.eventhub.local}"
ADMIN_API_HOST="${ADMIN_API_HOST:-https://admin-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}" WS_HOST="${WS_HOST:-wss://ws.ift.eventhub.local}"
ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-api.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" DEVOPS_SMOKE="/opt/eventhub-ift/devops/scripts/smoke-core.sh"
;; ;;
stage) stage)
API_HOST="${API_HOST:-https://api.stage.eventhub.local}" API_HOST="${API_HOST:-https://api.stage.eventhub.local}"
ADMIN_API_HOST="${ADMIN_API_HOST:-https://admin-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}" WS_HOST="${WS_HOST:-wss://ws.stage.eventhub.local}"
ADMIN_WS_HOST="${ADMIN_WS_HOST:-wss://admin-api.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" DEVOPS_SMOKE="/opt/eventhub-stage/devops/scripts/smoke-core.sh"
;; ;;
*) *)
@@ -41,6 +41,8 @@ fi
echo "=== API CT remote (${STAND}) ===" echo "=== API CT remote (${STAND}) ==="
echo " API_HOST=${API_HOST}" echo " API_HOST=${API_HOST}"
echo " ADMIN_API_HOST=${ADMIN_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 if ! docker image inspect eventhub-api-tests:local >/dev/null 2>&1; then
bash scripts/retry-docker-build.sh 5 60 -- \ bash scripts/retry-docker-build.sh 5 60 -- \
+14 -6
View File
@@ -88,7 +88,7 @@ test_list_admin_forbidden(Token) ->
%% @doc Логин с X-Forwarded-For записывает IP клиента в аудит. %% @doc Логин с X-Forwarded-For записывает IP клиента в аудит.
test_login_audit_ip(Token) -> 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(), Email = api_test_runner:admin_super_email(),
Password = api_test_runner:admin_super_password(), Password = api_test_runner:admin_super_password(),
Body = jsx:encode(#{<<"email">> => Email, <<"password">> => Password}), Body = jsx:encode(#{<<"email">> => Email, <<"password">> => Password}),
@@ -97,11 +97,19 @@ test_login_audit_ip(Token) ->
[{"X-Forwarded-For", "203.0.113.99"}] [{"X-Forwarded-For", "203.0.113.99"}]
), ),
Records = api_test_runner:admin_get(<<"/v1/admin/audit?action=login">>, Token), Records = api_test_runner:admin_get(<<"/v1/admin/audit?action=login">>, Token),
Forwarded = [R || R <- Records, maps:get(<<"ip">>, R) =:= <<"203.0.113.99">>], case api_test_runner:ct_mode() of
?assert(length(Forwarded) >= 1), "remote" ->
Login = hd(Forwarded), %% За Traefik на стенде XFF из CI может не совпасть; достаточно не unknown.
?assertEqual(<<"203.0.113.99">>, maps:get(<<"ip">>, Login)), Valid = [R || R <- Records, maps:get(<<"ip">>, R, <<"unknown">>) =/= <<"unknown">>],
ct:pal(" OK: ip=~s", [maps:get(<<"ip">>, Login)]). ?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.
%% ── Фильтрация ── %% ── Фильтрация ──
+1
View File
@@ -9,6 +9,7 @@
-module(api_test_runner). -module(api_test_runner).
-export([ -export([
ct_mode/0,
get_admin_url/0, get_admin_url/0,
get_base_url/0, get_base_url/0,
get_base_ws_url/0, get_base_ws_url/0,