Validate media description length
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
parent
855c5a234f
commit
c802f3b7f6
3 changed files with 54 additions and 3 deletions
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue