Split this cc test into two individual cases
This commit is contained in:
parent
23be24b92f
commit
d3adc3e05e
1 changed files with 34 additions and 24 deletions
|
|
@ -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"]
|
||||
|
||||
# For verification, also test with an explicit cc parameter
|
||||
# to show the cc field is completely replaced
|
||||
prepared_with_cc =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id,
|
||||
cc: ["https://example.com/specific/user"]
|
||||
})
|
||||
|
||||
{:ok, decoded_with_cc} = Jason.decode(prepared_with_cc.json)
|
||||
|
||||
# Verify cc is completely replaced with the provided value
|
||||
assert decoded_with_cc["cc"] == ["https://example.com/specific/user"]
|
||||
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" => [@as_public, "https://example.org/users/other"],
|
||||
"cc" => cc_with_public,
|
||||
"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: cc_with_public
|
||||
})
|
||||
|
||||
{: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 cc_with_public == decoded["cc"]
|
||||
end
|
||||
|
||||
test "cc parameter is preserved" do
|
||||
user = insert(:user)
|
||||
|
||||
activity =
|
||||
insert(:note_activity,
|
||||
user: user,
|
||||
data_attrs: %{
|
||||
"cc" => ["https://example.com/specific/user"],
|
||||
"to" => [user.follower_address]
|
||||
}
|
||||
)
|
||||
|
||||
prepared =
|
||||
Publisher.prepare_one(%{
|
||||
inbox: "https://remote.instance/users/someone/inbox",
|
||||
activity_id: activity.id,
|
||||
cc: ["https://example.com/specific/user"]
|
||||
})
|
||||
|
||||
{:ok, decoded} = Jason.decode(prepared.json)
|
||||
|
||||
assert decoded["cc"] == ["https://example.com/specific/user"]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue