diff options
author | marcin mikołajczak <git@mkljczk.pl> | 2022-02-06 17:41:15 +0100 |
---|---|---|
committer | marcin mikołajczak <git@mkljczk.pl> | 2022-02-06 17:41:15 +0100 |
commit | e473bcf7a0390584377d89ff68267a25fe31e44d (patch) | |
tree | 34686c246e9517ae9018175ffee93804935d59c0 /test | |
parent | 60deddb7e5b8bb10037cca6e6f11a5bbef298d39 (diff) | |
download | pleroma-e473bcf7a0390584377d89ff68267a25fe31e44d.tar.gz pleroma-e473bcf7a0390584377d89ff68267a25fe31e44d.zip |
Max media attachment count
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/web/common_api_test.exs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index 4b186ccfc..16af4b923 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -683,6 +683,32 @@ defmodule Pleroma.Web.CommonAPITest do assert {:ok, _activity} = CommonAPI.post(user, %{status: "12345"}) end + test "it validates media attachment limits are correctly enforced" do + clear_config([:instance, :max_media_attachments], 4) + + user = insert(:user) + + file = %Plug.Upload{ + content_type: "image/jpeg", + path: Path.absname("test/fixtures/image.jpg"), + filename: "an_image.jpg" + } + + {:ok, upload} = ActivityPub.upload(file, actor: user.ap_id) + + assert {:error, "Too many attachments"} = + CommonAPI.post(user, %{ + status: "", + media_ids: List.duplicate(upload.id, 5) + }) + + assert {:ok, _activity} = + CommonAPI.post(user, %{ + status: "", + media_ids: [upload.id] + }) + end + test "it can handle activities that expire" do user = insert(:user) |