Skip to content

Commit

Permalink
Persist remote_ip during recycling of a conn (#5792)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonRowe committed May 2, 2024
1 parent 5d3dc22 commit 1820877
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 @@ -499,6 +499,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 @@ -221,6 +221,14 @@ defmodule Phoenix.Test.ConnTest do
assert conn.host == "localhost"
end

test "remote_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 1820877

Please sign in to comment.