1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Plugs.LegacyAuthenticationPlugTest do
6 use Pleroma.Web.ConnCase
10 alias Pleroma.Plugs.LegacyAuthenticationPlug
18 "$6$9psBWV8gxkGOZWBz$PmfCycChoxeJ3GgGzwvhlgacb9mUoZ.KUXNCssekER4SJ7bOK53uXrHNb2e4i8yPFgSKyzaW9CcmrDXWIEMtD1"
24 test "it does nothing if a user is assigned", %{conn: conn, user: user} do
27 |> assign(:auth_credentials, %{username: "dude", password: "password"})
28 |> assign(:auth_user, user)
29 |> assign(:user, %User{})
33 |> LegacyAuthenticationPlug.call(%{})
35 assert ret_conn == conn
39 test "it authenticates the auth_user if present and password is correct and resets the password",
46 |> assign(:auth_credentials, %{username: "dude", password: "password"})
47 |> assign(:auth_user, user)
49 conn = LegacyAuthenticationPlug.call(conn, %{})
51 assert conn.assigns.user.id == user.id
55 test "it does nothing if the password is wrong", %{
61 |> assign(:auth_credentials, %{username: "dude", password: "wrong_password"})
62 |> assign(:auth_user, user)
66 |> LegacyAuthenticationPlug.call(%{})
68 assert conn == ret_conn
71 test "with no credentials or user it does nothing", %{conn: conn} do
74 |> LegacyAuthenticationPlug.call(%{})
76 assert ret_conn == conn