1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Plugs.SetUserSessionIdPlugTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Plugs.SetUserSessionIdPlug
11 setup %{conn: conn} do
15 signing_salt: "cooldude"
20 |> Plug.Session.call(Plug.Session.init(session_opts))
26 test "doesn't do anything if the user isn't set", %{conn: conn} do
29 |> SetUserSessionIdPlug.call(%{})
31 assert ret_conn == conn
34 test "sets the user_id in the session to the user id of the user assign", %{conn: conn} do
35 Code.ensure_compiled(Pleroma.User)
39 |> assign(:user, %User{id: 1})
40 |> SetUserSessionIdPlug.call(%{})
42 id = get_session(conn, :user_id)