logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/
commit: 71785d7ff7643ff99c042c6bbb5eb45eac2ad7a5
parent 5bf1a384c7ab5168ab1cea9e50f60ead8157fef7
Author: Lain Soykaf <lain@lain.com>
Date:   Fri,  5 Sep 2025 09:52:12 +0400

PublisherTest: Add test for signature replacement

Diffstat:

Mtest/pleroma/web/activity_pub/publisher_test.exs40++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+), 0 deletions(-)

diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs @@ -14,6 +14,8 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do alias Pleroma.Object alias Pleroma.Tests.ObanHelpers alias Pleroma.Web.ActivityPub.Publisher + alias Pleroma.Web.ActivityPub.Utils + alias Pleroma.Web.ActivityPub.ActivityPub alias Pleroma.Web.CommonAPI @as_public "https://www.w3.org/ns/activitystreams#Public" @@ -552,4 +554,42 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do assert decoded["cc"] == ["https://example.com/specific/user"] end + + describe "prepare_one/1 with reporter anonymization" do + test_with_mock "signs with the anonymized actor keys when Transmogrifier changes actor", + Pleroma.Signature, + [:passthrough], + sign: fn %Pleroma.User{} = user, headers -> + send(self(), {:signed_as, user.ap_id}) + "TESTSIG" + end do + placeholder = insert(:user) + reporter = insert(:user) + target_account = insert(:user) + + clear_config([:activitypub, :anonymize_reporter], true) + clear_config([:activitypub, :anonymize_reporter_local_nickname], placeholder.nickname) + + {:ok, reported} = CommonAPI.post(target_account, %{status: "content"}) + context = Utils.generate_context_id() + + {:ok, activity} = + ActivityPub.flag(%{ + actor: reporter, + context: context, + account: target_account, + statuses: [reported], + content: "reason" + }) + + _prepared = + Publisher.prepare_one(%{ + inbox: "http://remote.example/users/alice/inbox", + activity_id: activity.id + }) + + assert_received {:signed_as, ap_id} + assert ap_id == placeholder.ap_id + end + end end