diff options
author | Alex Gleason <alex@alexgleason.me> | 2021-12-03 00:11:38 -0600 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2021-12-03 00:11:38 -0600 |
commit | 8286ceb46522069607cc0a0dec864022606bf19d (patch) | |
tree | 5270f50d3b6b00d3d2796d2e611a2606ffeb4ff1 /test/pleroma/web/twitter_api | |
parent | 5da4f33bf136970706ddcf19bd701288acb141cf (diff) | |
parent | 235c4139d701f7d25dac2a152d8ab6e4afb1c20d (diff) | |
download | pleroma-8286ceb46522069607cc0a0dec864022606bf19d.tar.gz |
Merge remote-tracking branch 'origin/develop' into password-reset
Diffstat (limited to 'test/pleroma/web/twitter_api')
-rw-r--r-- | test/pleroma/web/twitter_api/twitter_api_test.exs | 4 | ||||
-rw-r--r-- | test/pleroma/web/twitter_api/util_controller_test.exs | 55 |
2 files changed, 43 insertions, 16 deletions
diff --git a/test/pleroma/web/twitter_api/twitter_api_test.exs b/test/pleroma/web/twitter_api/twitter_api_test.exs index 85629be04..2b8a4c3f5 100644 --- a/test/pleroma/web/twitter_api/twitter_api_test.exs +++ b/test/pleroma/web/twitter_api/twitter_api_test.exs @@ -139,9 +139,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do {:ok, user2} = TwitterAPI.register_user(data2) expected_text = - ~s(<span class="h-card"><a class="u-url mention" data-user="#{user1.id}" href="#{ - user1.ap_id - }" rel="ugc">@<span>john</span></a></span> test) + ~s(<span class="h-card"><a class="u-url mention" data-user="#{user1.id}" href="#{user1.ap_id}" rel="ugc">@<span>john</span></a></span> test) assert user2.bio == expected_text end diff --git a/test/pleroma/web/twitter_api/util_controller_test.exs b/test/pleroma/web/twitter_api/util_controller_test.exs index f030483d8..3380aec22 100644 --- a/test/pleroma/web/twitter_api/util_controller_test.exs +++ b/test/pleroma/web/twitter_api/util_controller_test.exs @@ -26,11 +26,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do test "it updates notification settings", %{user: user, conn: conn} do conn |> put( - "/api/pleroma/notification_settings?#{ - URI.encode_query(%{ - block_from_strangers: true - }) - }" + "/api/pleroma/notification_settings?#{URI.encode_query(%{block_from_strangers: true})}" ) |> json_response_and_validate_schema(:ok) @@ -45,11 +41,7 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do test "it updates notification settings to enable hiding contents", %{user: user, conn: conn} do conn |> put( - "/api/pleroma/notification_settings?#{ - URI.encode_query(%{ - hide_notification_contents: 1 - }) - }" + "/api/pleroma/notification_settings?#{URI.encode_query(%{hide_notification_contents: 1})}" ) |> json_response_and_validate_schema(:ok) @@ -302,9 +294,22 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do assert %{"error" => "Missing field: email."} = json_response_and_validate_schema(conn, 400) end - test "with proper permissions, valid password and blank email", %{ - conn: conn - } do + test "with proper permissions, valid password and blank email, when instance requires user email", + %{ + conn: conn + } do + orig_account_activation_required = + Pleroma.Config.get([:instance, :account_activation_required]) + + Pleroma.Config.put([:instance, :account_activation_required], true) + + on_exit(fn -> + Pleroma.Config.put( + [:instance, :account_activation_required], + orig_account_activation_required + ) + end) + conn = conn |> put_req_header("content-type", "multipart/form-data") @@ -313,6 +318,30 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do assert json_response_and_validate_schema(conn, 200) == %{"error" => "Email can't be blank."} end + test "with proper permissions, valid password and blank email, when instance does not require user email", + %{ + conn: conn + } do + orig_account_activation_required = + Pleroma.Config.get([:instance, :account_activation_required]) + + Pleroma.Config.put([:instance, :account_activation_required], false) + + on_exit(fn -> + Pleroma.Config.put( + [:instance, :account_activation_required], + orig_account_activation_required + ) + end) + + conn = + 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) == %{"status" => "success"} + end + test "with proper permissions, valid password and non unique email", %{ conn: conn } do |