towerops/test/towerops_web/remote_ip_test.exs
Graham McIntire 532d88ffb9
perf: disable Req retry for faster error tests
- Add retry: false to VISP Client HTTP requests
- Add retry: false to ReleaseChecker GitHub API requests
- Remove unused Plug.Conn import from RemoteIpLogger
- Remove unused default parameter from req_get/2

Results:
- VISP sync test: 7007ms → 113ms (62x faster)
- ReleaseChecker test: 7004ms → 17ms (402x faster)
- UserResetPasswordLive test: 1495ms → 284ms (5x faster)

Req's default retry behavior (1s, 2s, 4s exponential backoff) was
causing 7-second delays for HTTP 500/503 error responses in tests.
For these clients, immediate failure is preferred over retries.
2026-03-10 16:19:31 -05:00

18 lines
539 B
Elixir

defmodule ToweropsWeb.RemoteIpTest do
use ToweropsWeb.ConnCase, async: true
alias ToweropsWeb.RemoteIp
test "extracts the first forwarded IP from conn headers", %{conn: conn} do
conn =
conn
|> put_req_header("x-forwarded-for", "203.0.113.10, 10.0.0.1")
|> put_req_header("x-real-ip", "198.51.100.1")
assert RemoteIp.from_conn(conn) == "203.0.113.10"
end
test "formats IPv6 addresses in uppercase hex" do
assert RemoteIp.format({8193, 3512, 0, 0, 0, 0, 0, 1}) == "2001:DB8:0:0:0:0:0:1"
end
end