diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-08-10 20:33:00 +0200 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2021-08-13 17:57:11 +0200 |
commit | 0e2aebd036fd49386f373327d933dd380b14b649 (patch) | |
tree | d47f1e962017390f7aa96bd88207ccdf8b9a1ea7 /test | |
parent | 3961422f853934a598a36d3ec10659158affb6ed (diff) | |
download | pleroma-0e2aebd036fd49386f373327d933dd380b14b649.tar.gz |
TwitterAPI: Make change_email require body params instead of query
Backport of: https://git.pleroma.social/pleroma/pleroma/-/merge_requests/3503
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/twitter_api/util_controller_test.exs | 51 |
1 files changed, 21 insertions, 30 deletions
diff --git a/test/pleroma/web/twitter_api/util_controller_test.exs b/test/pleroma/web/twitter_api/util_controller_test.exs index fe3d99272..f030483d8 100644 --- a/test/pleroma/web/twitter_api/util_controller_test.exs +++ b/test/pleroma/web/twitter_api/util_controller_test.exs @@ -261,11 +261,8 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do conn = conn |> assign(:token, nil) - |> post( - "/api/pleroma/change_email?#{ - URI.encode_query(%{password: "hi", email: "test@test.com"}) - }" - ) + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "hi", email: "test@test.com"}) assert json_response_and_validate_schema(conn, 403) == %{ "error" => "Insufficient permissions: write:accounts." @@ -274,12 +271,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do test "with proper permissions and invalid password", %{conn: conn} do conn = - post( - conn, - "/api/pleroma/change_email?#{ - URI.encode_query(%{password: "hi", email: "test@test.com"}) - }" - ) + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "hi", email: "test@test.com"}) assert json_response_and_validate_schema(conn, 200) == %{"error" => "Invalid password."} end @@ -288,10 +282,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do conn: conn } do conn = - post( - conn, - "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: "foobar"})}" - ) + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "test", email: "foobar"}) assert json_response_and_validate_schema(conn, 200) == %{ "error" => "Email has invalid format." @@ -301,7 +294,10 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do test "with proper permissions, valid password and no email", %{ conn: conn } do - conn = post(conn, "/api/pleroma/change_email?#{URI.encode_query(%{password: "test"})}") + conn = + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "test"}) assert %{"error" => "Missing field: email."} = json_response_and_validate_schema(conn, 400) end @@ -310,10 +306,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do conn: conn } do conn = - post( - conn, - "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: ""})}" - ) + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "test", email: ""}) assert json_response_and_validate_schema(conn, 200) == %{"error" => "Email can't be blank."} end @@ -324,10 +319,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do user = insert(:user) conn = - post( - conn, - "/api/pleroma/change_email?#{URI.encode_query(%{password: "test", email: user.email})}" - ) + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "test", email: user.email}) assert json_response_and_validate_schema(conn, 200) == %{ "error" => "Email has already been taken." @@ -338,12 +332,9 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do conn: conn } do conn = - post( - conn, - "/api/pleroma/change_email?#{ - URI.encode_query(%{password: "test", email: "cofe@foobar.com"}) - }" - ) + conn + |> put_req_header("content-type", "multipart/form-data") + |> post("/api/pleroma/change_email", %{password: "test", email: "cofe@foobar.com"}) assert json_response_and_validate_schema(conn, 200) == %{"status" => "success"} end |