Skip to content

Commit aa248cf

Browse files
committed
Isolate auth API test rate buckets
1 parent ca9e5e8 commit aa248cf

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

test/api/auth_plug_test.exs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,21 @@ defmodule OptimalEngine.API.AuthPlugTest do
3131
conn(method, path, Jason.encode!(b))
3232
|> put_req_header("content-type", "application/json")
3333
end
34+
|> put_peer_data(%{
35+
address: unique_loopback_address(),
36+
port: 0,
37+
ssl_cert: nil
38+
})
3439

3540
conn = Enum.reduce(headers, conn, fn {k, v}, c -> put_req_header(c, k, v) end)
3641
Router.call(conn, @opts)
3742
end
3843

44+
defp unique_loopback_address do
45+
n = System.unique_integer([:positive])
46+
{127, rem(div(n, 65_536), 256), rem(div(n, 256), 256), rem(n, 254) + 1}
47+
end
48+
3949
# Temporarily force auth_required: true for the duration of a test.
4050
defp with_auth_required(fun) do
4151
original = Application.get_env(:optimal_engine, :auth, [])

0 commit comments

Comments
 (0)