1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Plugs.AdminSecretAuthenticationPlugTest do
6 use Pleroma.Web.ConnCase, async: true
9 alias Pleroma.Plugs.AdminSecretAuthenticationPlug
11 test "does nothing if a user is assigned", %{conn: conn} do
16 |> assign(:user, user)
20 |> AdminSecretAuthenticationPlug.call(%{})
22 assert conn == ret_conn
25 test "with secret set and given in the 'admin_token' parameter, it assigns an admin user", %{
28 Pleroma.Config.put(:admin_token, "password123")
31 %{conn | params: %{"admin_token" => "wrong_password"}}
32 |> AdminSecretAuthenticationPlug.call(%{})
34 refute conn.assigns[:user]
37 %{conn | params: %{"admin_token" => "password123"}}
38 |> AdminSecretAuthenticationPlug.call(%{})
40 assert conn.assigns[:user].info.is_admin