diff options
author | marcin mikołajczak <git@mkljczk.pl> | 2024-08-17 19:58:32 +0200 |
---|---|---|
committer | marcin mikołajczak <git@mkljczk.pl> | 2024-08-17 19:58:32 +0200 |
commit | c802f3b7f61e1c4bbe2f4eec757802e30f88b6a5 (patch) | |
tree | 8480b4b162cef74a2b983ba0929bda4ce6dfabbe /test | |
parent | 855c5a234f4ca743303f1b88974665d7b9f58684 (diff) | |
download | pleroma-c802f3b7f61e1c4bbe2f4eec757802e30f88b6a5.tar.gz pleroma-c802f3b7f61e1c4bbe2f4eec757802e30f88b6a5.zip |
Validate media description length
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/mastodon_api/update_credentials_test.exs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/pleroma/web/mastodon_api/update_credentials_test.exs b/test/pleroma/web/mastodon_api/update_credentials_test.exs index 28d3b00db..97ad2e849 100644 --- a/test/pleroma/web/mastodon_api/update_credentials_test.exs +++ b/test/pleroma/web/mastodon_api/update_credentials_test.exs @@ -472,6 +472,33 @@ defmodule Pleroma.Web.MastodonAPI.UpdateCredentialsTest do assert user.avatar["name"] == "me and pleroma tan" end + test "limit", %{user: user, conn: conn} do + new_header = %Plug.Upload{ + content_type: "image/jpeg", + path: Path.absname("test/fixtures/image.jpg"), + filename: "an_image.jpg" + } + + assert user.banner == %{} + + conn + |> patch("/api/v1/accounts/update_credentials", %{"header" => new_header}) + + description_limit = Config.get([:instance, :description_limit], 100) + + description = String.duplicate(".", description_limit + 1) + + conn = + conn + |> assign(:user, User.get_by_id(user.id)) + |> patch("/api/v1/accounts/update_credentials", %{ + "header_description" => description + }) + + assert %{"error" => "Banner description is too long"} = + json_response_and_validate_schema(conn, 413) + end + test "Strip / from upload files", %{user: user, conn: conn} do new_image = %Plug.Upload{ content_type: "image/jpeg", |