diff options
author | Alex Gleason <alex@alexgleason.me> | 2022-02-06 18:25:14 +0000 |
---|---|---|
committer | Alex Gleason <alex@alexgleason.me> | 2022-02-06 18:25:14 +0000 |
commit | fa8e2ffa3f493d5b2911507b0ac06094615e9d8f (patch) | |
tree | 34686c246e9517ae9018175ffee93804935d59c0 /test | |
parent | 60deddb7e5b8bb10037cca6e6f11a5bbef298d39 (diff) | |
parent | e473bcf7a0390584377d89ff68267a25fe31e44d (diff) | |
download | pleroma-fa8e2ffa3f493d5b2911507b0ac06094615e9d8f.tar.gz pleroma-fa8e2ffa3f493d5b2911507b0ac06094615e9d8f.zip |
Merge branch 'max_media_attachments' into 'develop'
Allow specifying max media attachment count
Closes #2665
See merge request pleroma/pleroma!3630
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) |