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,