logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

user_fetcher_plug_test.exs (919B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Plugs.UserFetcherPlugTest do
  5. use Pleroma.Web.ConnCase, async: true
  6. alias Pleroma.Plugs.UserFetcherPlug
  7. import Pleroma.Factory
  8. setup do
  9. user = insert(:user)
  10. %{user: user}
  11. end
  12. test "if an auth_credentials assign is present, it tries to fetch the user and assigns it", %{
  13. conn: conn,
  14. user: user
  15. } do
  16. conn =
  17. conn
  18. |> assign(:auth_credentials, %{
  19. username: user.nickname,
  20. password: nil
  21. })
  22. conn =
  23. conn
  24. |> UserFetcherPlug.call(%{})
  25. assert conn.assigns[:auth_user] == user
  26. end
  27. test "without a credential assign it doesn't do anything", %{conn: conn} do
  28. ret_conn =
  29. conn
  30. |> UserFetcherPlug.call(%{})
  31. assert conn == ret_conn
  32. end
  33. end