Added endpoint for user account deletion
[akkoma] / test / web / common_api / common_api_utils_test.exs
1 defmodule Pleroma.Web.CommonAPI.UtilsTest do
2 alias Pleroma.Web.CommonAPI.Utils
3 alias Pleroma.Builders.{UserBuilder}
4 use Pleroma.DataCase
5
6 test "it adds attachment links to a given text and attachment set" do
7 name =
8 "Sakura%20Mana%20%E2%80%93%20Turned%20on%20by%20a%20Senior%20OL%20with%20a%20Temptating%20Tight%20Skirt-s%20Full%20Hipline%20and%20Panty%20Shot-%20Beautiful%20Thick%20Thighs-%20and%20Erotic%20Ass-%20-2015-%20--%20Oppaitime%208-28-2017%206-50-33%20PM.png"
9
10 attachment = %{
11 "url" => [%{"href" => name}]
12 }
13
14 res = Utils.add_attachments("", [attachment])
15
16 assert res ==
17 "<br><a href=\"#{name}\" class='attachment'>Sakura Mana – Turned on by a Se…</a>"
18 end
19
20 describe "it confirms the password given is the current users password" do
21 test "with no credentials" do
22 assert Utils.confirm_current_password(nil, %{"password" => "test"}) ==
23 {:error, "Invalid credentials."}
24 end
25
26 test "with incorrect password given" do
27 {:ok, user} = UserBuilder.insert()
28
29 assert Utils.confirm_current_password(user, %{"password" => ""}) ==
30 {:error, "Invalid password."}
31 end
32
33 test "with correct password given" do
34 {:ok, user} = UserBuilder.insert()
35 assert Utils.confirm_current_password(user, %{"password" => "test"}) == {:ok, user}
36 end
37 end
38 end