test: add regression test for to/cc clobbering
authorWilliam Pitcock <nenolod@dereferenced.org>
Fri, 18 Jan 2019 22:32:01 +0000 (22:32 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Fri, 18 Jan 2019 22:32:01 +0000 (22:32 +0000)
test/web/activity_pub/transmogrifier_test.exs

index 87d0ab5596441403eba64e51f3cc81a14c500fb9..6107ac4f74e5a16b0b6afb7f38ce64f82c94c7d3 100644 (file)
@@ -288,6 +288,22 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert Activity.get_create_activity_by_object_ap_id(data["object"]).id == activity.id
     end
 
+    test "it does not clobber the addressing on announce activities" do
+      user = insert(:user)
+      {:ok, activity} = CommonAPI.post(user, %{"status" => "hey"})
+
+      data =
+        File.read!("test/fixtures/mastodon-announce.json")
+        |> Poison.decode!()
+        |> Map.put("object", activity.data["object"]["id"])
+        |> Map.put("to", ["http://mastodon.example.org/users/admin/followers"])
+        |> Map.put("cc", [])
+
+      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+
+      assert data["to"] == ["http://mastodon.example.org/users/admin/followers"]
+    end
+
     test "it works for incoming update activities" do
       data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!()