diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-12-13 16:15:33 -0500 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-12-13 17:07:29 -0500 |
commit | 8672ad6b00e1bba59cd6e4f0a09fd26bc6ba6bd6 (patch) | |
tree | 890bd89aee5c21b1fe6106bf33fa2cdb89d2d826 /test | |
parent | 0b2119d4a791b3623b304b0bab683609d23271d4 (diff) | |
download | pleroma-8672ad6b00e1bba59cd6e4f0a09fd26bc6ba6bd6.tar.gz |
TwitterAPI: allow deleting one's own account with request body
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/twitter_api/util_controller_test.exs | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/test/pleroma/web/twitter_api/util_controller_test.exs b/test/pleroma/web/twitter_api/util_controller_test.exs index f030483d8..e944228cc 100644 --- a/test/pleroma/web/twitter_api/util_controller_test.exs +++ b/test/pleroma/web/twitter_api/util_controller_test.exs @@ -444,7 +444,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do test "with proper permissions and wrong or missing password", %{conn: conn} do for params <- [%{"password" => "hi"}, %{}] do - ret_conn = post(conn, "/api/pleroma/delete_account", params) + ret_conn = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/pleroma/delete_account", params) assert json_response_and_validate_schema(ret_conn, 200) == %{ "error" => "Invalid password." @@ -452,8 +455,28 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do end end - test "with proper permissions and valid password", %{conn: conn, user: user} do - conn = post(conn, "/api/pleroma/delete_account?password=test") + test "with proper permissions and valid password (URL query)", %{conn: conn, user: user} do + conn = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/pleroma/delete_account?password=test") + + ObanHelpers.perform_all() + assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"} + + user = User.get_by_id(user.id) + refute user.is_active + assert user.name == nil + assert user.bio == "" + assert user.password_hash == nil + end + + test "with proper permissions and valid password (JSON body)", %{conn: conn, user: user} do + conn = + conn + |> put_req_header("content-type", "application/json") + |> post("/api/pleroma/delete_account", %{password: "test"}) + ObanHelpers.perform_all() assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"} |