tests: add tests for DM sanitizer
authorWilliam Pitcock <nenolod@dereferenced.org>
Sat, 17 Nov 2018 16:18:40 +0000 (16:18 +0000)
committerWilliam Pitcock <nenolod@dereferenced.org>
Sun, 20 Jan 2019 02:27:48 +0000 (02:27 +0000)
test/web/activity_pub/transmogrifier_test.exs

index 6107ac4f74e5a16b0b6afb7f38ce64f82c94c7d3..5aa136e65e16909ae8cc90fc0a29c43d00580eb5 100644 (file)
@@ -162,6 +162,36 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert data["object"]["url"] == "https://prismo.news/posts/83"
     end
 
+    test "it cleans up incoming notices which are not really DMs" do
+      user = insert(:user)
+      other_user = insert(:user)
+
+      to = [user.ap_id, other_user.ap_id]
+
+      data =
+        File.read!("test/fixtures/mastodon-post-activity.json")
+        |> Poison.decode!()
+        |> Map.put("to", to)
+        |> Map.put("cc", [])
+
+      object =
+        data["object"]
+        |> Map.put("to", to)
+        |> Map.put("cc", [])
+
+      data = Map.put(data, "object", object)
+
+      {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
+
+      assert data["to"] == []
+      assert data["cc"] == to
+
+      object = data["object"]
+
+      assert object["to"] == []
+      assert object["cc"] == to
+    end
+
     test "it works for incoming follow requests" do
       user = insert(:user)