1 defmodule Pleroma.Plugs.BasicAuthDecoderPlugTest do
2 use Pleroma.Web.ConnCase, async: true
4 alias Pleroma.Plugs.BasicAuthDecoderPlug
6 defp basic_auth_enc(username, password) do
7 "Basic " <> Base.encode64("#{username}:#{password}")
10 test "it puts the decoded credentials into the assigns", %{conn: conn} do
11 header = basic_auth_enc("moonman", "iloverobek")
15 |> put_req_header("authorization", header)
16 |> BasicAuthDecoderPlug.call(%{})
18 assert conn.assigns[:auth_credentials] == %{
20 password: "iloverobek"
24 test "without a authorization header it doesn't do anything", %{conn: conn} do
27 |> BasicAuthDecoderPlug.call(%{})
29 assert conn == ret_conn