Fix typo in CSP Report-To header name
[akkoma] / test / pleroma / web / plugs / user_enabled_plug_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
6 use Pleroma.Web.ConnCase
7
8 alias Pleroma.Web.Plugs.UserEnabledPlug
9 import Pleroma.Factory
10
11 setup do: clear_config([:instance, :account_activation_required])
12
13 test "doesn't do anything if the user isn't set", %{conn: conn} do
14 ret_conn =
15 conn
16 |> UserEnabledPlug.call(%{})
17
18 assert ret_conn == conn
19 end
20
21 test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
22 %{conn: conn} do
23 clear_config([:instance, :account_activation_required], true)
24
25 user = insert(:user, is_confirmed: false)
26
27 conn =
28 conn
29 |> assign(:user, user)
30 |> UserEnabledPlug.call(%{})
31
32 assert conn.assigns.user == nil
33 end
34
35 test "with a user that is deactivated, it removes that user", %{conn: conn} do
36 user = insert(:user, is_active: false)
37
38 conn =
39 conn
40 |> assign(:user, user)
41 |> UserEnabledPlug.call(%{})
42
43 assert conn.assigns.user == nil
44 end
45
46 test "with a user that is not deactivated, it does nothing", %{conn: conn} do
47 user = insert(:user)
48
49 conn =
50 conn
51 |> assign(:user, user)
52
53 ret_conn =
54 conn
55 |> UserEnabledPlug.call(%{})
56
57 assert conn == ret_conn
58 end
59 end