diff options
Diffstat (limited to 'test/pleroma/web/common_api_test.exs')
-rw-r--r-- | test/pleroma/web/common_api_test.exs | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/test/pleroma/web/common_api_test.exs b/test/pleroma/web/common_api_test.exs index ad0b87543..b502aaa03 100644 --- a/test/pleroma/web/common_api_test.exs +++ b/test/pleroma/web/common_api_test.exs @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/> +# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/> # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Web.CommonAPITest do @@ -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) @@ -1207,6 +1233,18 @@ defmodule Pleroma.Web.CommonAPITest do refute User.subscribed_to?(follower, followed) end + test "also unpins a user" do + [follower, followed] = insert_pair(:user) + {:ok, follower, followed, _} = CommonAPI.follow(follower, followed) + {:ok, _endorsement} = User.endorse(follower, followed) + + assert User.endorses?(follower, followed) + + {:ok, follower} = CommonAPI.unfollow(follower, followed) + + refute User.endorses?(follower, followed) + end + test "cancels a pending follow for a local user" do follower = insert(:user) followed = insert(:user, is_locked: true) |