Failing {:phx_gen_auth, "~> 0.6"} test after upgrading to Phoenix 1.6 from Phoenix 1.5.8

In a phoenix 1.5.8 app I ran phx_gen_auth which implemented tests around the code it generated. After upgrading to phoenix 1.6.2 a single test has begun failing. A partial of the failing test is:

user_auth_test.exs

test "stores the path to redirect to on GET", %{conn: conn} do
      halted_conn =
        %{conn | request_path: "/foo", query_string: ""}
        |> fetch_flash()
        |> UserAuth.require_authenticated_user([])

      assert halted_conn.halted
      assert get_session(halted_conn, :user_return_to) == "/foo"
end

The result is:

Assertion with == failed
     code:  assert get_session(halted_conn, :user_return_to) == "/foo"
     left:  "/"
     right: "/foo"

All other tests are passing.

My dependencies are:

mix.exs
...
defp deps do
    [
      {:bamboo, "~> 2.0.1"},
      {:bamboo_phoenix, "~> 1.0.0"},
      {:bcrypt_elixir, "~> 2.0"},
      {:decimal, "~> 2.0"},
      {:dialyxir, "~> 1.1", only: [:dev, :test], runtime: false},
      {:ex_machina, "~> 2.7.0", only: [:dev, :test]},
      {:httpoison, "~> 1.8"},
      {:sweet_xml, "~> 0.7.0"},
      {:typed_struct, "~> 0.2.1"},
      {:xml_builder, "~> 2.1"},
      {:phoenix, "~> 1.6"},
      {:phoenix_ecto, "~> 4.4"},
      {:ecto_sql, "~> 3.6"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 3.0"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_view, "~> 0.16"},
      {:floki, ">= 0.30.0", only: :test},
      {:phoenix_live_dashboard, "~> 0.5"},
      {:esbuild, "~> 0.2", runtime: Mix.env() == :dev},
      {:swoosh, "~> 1.3"},
      {:telemetry_metrics, "~> 0.6"},
      {:telemetry_poller, "~> 1.0"},
      {:gettext, "~> 0.18"},
      {:jason, "~> 1.2"},
      {:plug_cowboy, "~> 2.5"}
    ]
  end

I have deleted _build, deps and mix.lock and rebuilt them to troubleshoot as well having followed the code through Plug.Conn and Phoenix.Controller.

I have run out of ideas to troubleshoot this and I think it’s important functionality so I’d like to see the test passing again. I’m looking too the community for any ideas.

maybe due the upgrade, you have to change (at least this differs to my code, and I remember I have to change something, maybe more)

%{conn | request_path: "/foo", query_string: ""}

to

%{conn | path_info: ["foo"], query_string: ""}
1 Like

… and by the way, welcome to the elixir forum!

… and it is always recommended to take a look at the change logs

1 Like

path_info is the solution. Thanks for unblocking me on this! I will also check out the change logs. That will be a new first step for me.

1 Like