Skip to content

Commit

Permalink
Persist remote_ip during recycling of a conn
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed Apr 22, 2024
1 parent dfb0c00 commit ef503b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/phoenix/test/conn_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ defmodule Phoenix.ConnTest do
def recycle(conn, headers \\ ~w(accept accept-language authorization)) do
build_conn()
|> Map.put(:host, conn.host)
|> Map.put(:remote_ip, conn.remote_ip)
|> Plug.Test.recycle_cookies(conn)
|> Plug.Test.put_peer_data(Plug.Conn.get_peer_data(conn))
|> copy_headers(conn.req_headers, headers)
Expand Down
8 changes: 8 additions & 0 deletions test/phoenix/test/conn_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ defmodule Phoenix.Test.ConnTest do
assert conn.host == "localhost"
end

test "remove_ip is persisted" do
conn =
%Plug.Conn{build_conn(:get, "http://localhost/", nil) | remote_ip: {192, 168, 0, 1}}
|> recycle()

assert conn.remote_ip == {192, 168, 0, 1}
end

test "cookies are persisted" do
conn =
build_conn()
Expand Down

0 comments on commit ef503b8

Please sign in to comment.