1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.SetUserSessionIdPlugTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Helpers.AuthHelper
9 alias Pleroma.Web.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
27 ret_conn = SetUserSessionIdPlug.call(conn, %{})
29 assert ret_conn == conn
32 test "sets session token basing on :token assign", %{conn: conn} do
33 %{user: user, token: oauth_token} = oauth_access(["read"])
37 |> assign(:user, user)
38 |> assign(:token, oauth_token)
39 |> SetUserSessionIdPlug.call(%{})
41 assert AuthHelper.get_session_token(ret_conn) == oauth_token.token