1 defmodule Pleroma.Plugs.SessionAuthenticationPlugTest do
2 use Pleroma.Web.ConnCase, async: true
4 alias Pleroma.Plugs.SessionAuthenticationPlug
11 signing_salt: "cooldude"
16 |> Plug.Session.call(Plug.Session.init(session_opts))
18 |> assign(:auth_user, %User{id: 1})
23 test "it does nothing if a user is assigned", %{conn: conn} do
26 |> assign(:user, %User{})
30 |> SessionAuthenticationPlug.call(%{})
32 assert ret_conn == conn
35 test "if the auth_user has the same id as the user_id in the session, it assigns the user", %{
40 |> put_session(:user_id, conn.assigns.auth_user.id)
41 |> SessionAuthenticationPlug.call(%{})
43 assert conn.assigns.user == conn.assigns.auth_user
46 test "if the auth_user has a different id as the user_id in the session, it does nothing", %{
51 |> put_session(:user_id, -1)
55 |> SessionAuthenticationPlug.call(%{})
57 assert ret_conn == conn