1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.UserEnabledPlugTest do
6 use Pleroma.Web.ConnCase
8 alias Pleroma.Web.Plugs.UserEnabledPlug
11 setup do: clear_config([:instance, :account_activation_required])
13 test "doesn't do anything if the user isn't set", %{conn: conn} do
16 |> UserEnabledPlug.call(%{})
18 assert ret_conn == conn
21 test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
23 clear_config([:instance, :account_activation_required], true)
25 user = insert(:user, is_confirmed: false)
29 |> assign(:user, user)
30 |> UserEnabledPlug.call(%{})
32 assert conn.assigns.user == nil
35 test "with a user that is deactivated, it removes that user", %{conn: conn} do
36 user = insert(:user, is_active: false)
40 |> assign(:user, user)
41 |> UserEnabledPlug.call(%{})
43 assert conn.assigns.user == nil
46 test "with a user that is not deactivated, it does nothing", %{conn: conn} do
51 |> assign(:user, user)
55 |> UserEnabledPlug.call(%{})
57 assert conn == ret_conn