1 defmodule Pleroma.Plugs.AdminSecretAuthenticationPlugTest do
2 use Pleroma.Web.ConnCase, async: true
5 alias Pleroma.Plugs.AdminSecretAuthenticationPlug
7 test "does nothing if a user is assigned", %{conn: conn} do
12 |> assign(:user, user)
16 |> AdminSecretAuthenticationPlug.call(%{})
18 assert conn == ret_conn
21 test "with secret set and given in the 'admin_token' parameter, it assigns an admin user", %{
24 Pleroma.Config.put(:admin_token, "password123")
27 %{conn | params: %{"admin_token" => "wrong_password"}}
28 |> AdminSecretAuthenticationPlug.call(%{})
30 refute conn.assigns[:user]
33 %{conn | params: %{"admin_token" => "password123"}}
34 |> AdminSecretAuthenticationPlug.call(%{})
36 assert conn.assigns[:user].info.is_admin