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.

30 lines
701B

  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.EnsureUserKeyPlugTest do
  5. use Pleroma.Web.ConnCase, async: true
  6. alias Pleroma.Plugs.EnsureUserKeyPlug
  7. test "if the conn has a user key set, it does nothing", %{conn: conn} do
  8. conn =
  9. conn
  10. |> assign(:user, 1)
  11. ret_conn =
  12. conn
  13. |> EnsureUserKeyPlug.call(%{})
  14. assert conn == ret_conn
  15. end
  16. test "if the conn has no key set, it sets it to nil", %{conn: conn} do
  17. conn =
  18. conn
  19. |> EnsureUserKeyPlug.call(%{})
  20. assert Map.has_key?(conn.assigns, :user)
  21. end
  22. end