commit: d3adc3e05e09fdcb663ec1a3e20c1bc2d04a6ab5
parent 23be24b92fa4f868b814b2c6927f2a6a69fa882d
Author: Mark Felder <feld@feld.me>
Date: Thu, 12 Jun 2025 21:59:26 -0700
Split this cc test into two individual cases
Diffstat:
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/test/pleroma/web/activity_pub/publisher_test.exs b/test/pleroma/web/activity_pub/publisher_test.exs
@@ -521,9 +521,11 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
assert decoded["cc"] == []
end
- test "retains public address in cc for unlisted activities" do
+ test "unlisted activities retain public address in cc" do
user = insert(:user)
+ # simulate unlistd activity by only having
+ # public address in cc
activity =
insert(:note_activity,
user: user,
@@ -535,58 +537,66 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
assert @as_public in activity.data["cc"]
- # Call prepare_one without an explicit cc parameter (default in production)
prepared =
Publisher.prepare_one(%{
inbox: "https://remote.instance/users/someone/inbox",
activity_id: activity.id
})
- # Parse the JSON to verify the cc field in the federated message
{:ok, decoded} = Jason.decode(prepared.json)
- # The public address should be preserved in the cc field
- # Currently this will fail because it's being removed
assert @as_public in decoded["cc"]
+ end
+
+ test "public address in cc parameter is preserved" do
+ user = insert(:user)
+
+ cc_with_public = [@as_public, "https://example.org/users/other"]
+
+ activity =
+ insert(:note_activity,
+ user: user,
+ data_attrs: %{
+ "cc" => cc_with_public,
+ "to" => [user.follower_address]
+ }
+ )
+
+ assert @as_public in activity.data["cc"]
- # For verification, also test with an explicit cc parameter
- # to show the cc field is completely replaced
- prepared_with_cc =
+ prepared =
Publisher.prepare_one(%{
inbox: "https://remote.instance/users/someone/inbox",
activity_id: activity.id,
- cc: ["https://example.com/specific/user"]
+ cc: cc_with_public
})
- {:ok, decoded_with_cc} = Jason.decode(prepared_with_cc.json)
+ {:ok, decoded} = Jason.decode(prepared.json)
- # Verify cc is completely replaced with the provided value
- assert decoded_with_cc["cc"] == ["https://example.com/specific/user"]
+ assert cc_with_public == decoded["cc"]
end
- test "public address in cc parameter is preserved" do
+ test "cc parameter is preserved" do
user = insert(:user)
activity =
insert(:note_activity,
user: user,
data_attrs: %{
- "cc" => [@as_public, "https://example.org/users/other"],
+ "cc" => ["https://example.com/specific/user"],
"to" => [user.follower_address]
}
)
- assert @as_public in activity.data["cc"]
-
- prepared_with_public_cc =
+ prepared =
Publisher.prepare_one(%{
inbox: "https://remote.instance/users/someone/inbox",
activity_id: activity.id,
- cc: [@as_public]
+ cc: ["https://example.com/specific/user"]
})
- {:ok, decoded_with_public_cc} = Jason.decode(prepared_with_public_cc.json)
+ {:ok, decoded} = Jason.decode(prepared.json)
- assert @as_public in decoded_with_public_cc["cc"]
+ assert decoded["cc"] == ["https://example.com/specific/user"]
end
end