1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Plugs.BasicAuthDecoderPlugTest do
6 use Pleroma.Web.ConnCase, async: true
8 alias Pleroma.Plugs.BasicAuthDecoderPlug
10 defp basic_auth_enc(username, password) do
11 "Basic " <> Base.encode64("#{username}:#{password}")
14 test "it puts the decoded credentials into the assigns", %{conn: conn} do
15 header = basic_auth_enc("moonman", "iloverobek")
19 |> put_req_header("authorization", header)
20 |> BasicAuthDecoderPlug.call(%{})
22 assert conn.assigns[:auth_credentials] == %{
24 password: "iloverobek"
28 test "without a authorization header it doesn't do anything", %{conn: conn} do
31 |> BasicAuthDecoderPlug.call(%{})
33 assert conn == ret_conn