logo

pleroma

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

user_enabled_plug_test.exs (1442B)


  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.UserEnabledPlugTest do
  5. use Pleroma.Web.ConnCase, async: true
  6. alias Pleroma.Plugs.UserEnabledPlug
  7. import Pleroma.Factory
  8. setup do: clear_config([:instance, :account_activation_required])
  9. test "doesn't do anything if the user isn't set", %{conn: conn} do
  10. ret_conn =
  11. conn
  12. |> UserEnabledPlug.call(%{})
  13. assert ret_conn == conn
  14. end
  15. test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
  16. %{conn: conn} do
  17. Pleroma.Config.put([:instance, :account_activation_required], true)
  18. user = insert(:user, confirmation_pending: true)
  19. conn =
  20. conn
  21. |> assign(:user, user)
  22. |> UserEnabledPlug.call(%{})
  23. assert conn.assigns.user == nil
  24. end
  25. test "with a user that is deactivated, it removes that user", %{conn: conn} do
  26. user = insert(:user, deactivated: true)
  27. conn =
  28. conn
  29. |> assign(:user, user)
  30. |> UserEnabledPlug.call(%{})
  31. assert conn.assigns.user == nil
  32. end
  33. test "with a user that is not deactivated, it does nothing", %{conn: conn} do
  34. user = insert(:user)
  35. conn =
  36. conn
  37. |> assign(:user, user)
  38. ret_conn =
  39. conn
  40. |> UserEnabledPlug.call(%{})
  41. assert conn == ret_conn
  42. end
  43. end