Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
741B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Plugs.EnsureAuthenticatedPlugTest do
  5. use Pleroma.Web.ConnCase, async: true
  6. alias Pleroma.Plugs.EnsureAuthenticatedPlug
  7. alias Pleroma.User
  8. test "it halts if no user is assigned", %{conn: conn} do
  9. conn =
  10. conn
  11. |> EnsureAuthenticatedPlug.call(%{})
  12. assert conn.status == 403
  13. assert conn.halted == true
  14. end
  15. test "it continues if a user is assigned", %{conn: conn} do
  16. conn =
  17. conn
  18. |> assign(:user, %User{})
  19. ret_conn =
  20. conn
  21. |> EnsureAuthenticatedPlug.call(%{})
  22. assert ret_conn == conn
  23. end
  24. end