tests: transmogrifier: add explicit regression tests for JSON-LD string to single...
authorAriadne Conill <ariadne@dereferenced.org>
Wed, 23 Oct 2019 00:43:31 +0000 (19:43 -0500)
committerAriadne Conill <ariadne@dereferenced.org>
Wed, 23 Oct 2019 00:43:31 +0000 (19:43 -0500)
There appears to be confusion on whether or not Pleroma can handle this particular
sin of JSON-LD.  It can, and we will add regression tests to prove that it can handle
this particular sin.  Which, by the way, this is actually not a "feature" of JSON-LD,
but whatever.

test/web/activity_pub/transmogrifier_test.exs

index dbb6e59b0acc29ed74d34e665a6d65c87a5e938c..77e041b4a4fa5de4112b59baf948b1d46ed69217 100644 (file)
@@ -1106,6 +1106,50 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
       assert activity.data["actor"] == other_user.ap_id
       assert activity.data["cc"] == [user.ap_id]
     end
+
+    test "it correctly processes messages with non-array to field" do
+      user = insert(:user)
+
+      message = %{
+        "@context" => "https://www.w3.org/ns/activitystreams",
+        "to" => "https://www.w3.org/ns/activitystreams#Public",
+        "type" => "Create",
+        "object" => %{
+          "content" => "blah blah blah",
+          "type" => "Note",
+          "attributedTo" => user.ap_id,
+          "inReplyTo" => nil
+        },
+        "actor" => user.ap_id
+      }
+
+      assert {:ok, activity} = Transmogrifier.handle_incoming(message)
+
+      assert ["https://www.w3.org/ns/activitystreams#Public"] == activity.data["to"]
+    end
+
+    test "it correctly processes messages with non-array cc field" do
+      user = insert(:user)
+
+      message = %{
+        "@context" => "https://www.w3.org/ns/activitystreams",
+        "to" => user.follower_address,
+        "cc" => "https://www.w3.org/ns/activitystreams#Public",
+        "type" => "Create",
+        "object" => %{
+          "content" => "blah blah blah",
+          "type" => "Note",
+          "attributedTo" => user.ap_id,
+          "inReplyTo" => nil
+        },
+        "actor" => user.ap_id
+      }
+
+      assert {:ok, activity} = Transmogrifier.handle_incoming(message)
+
+      assert ["https://www.w3.org/ns/activitystreams#Public"] == activity.data["cc"]
+      assert [user.follower_address] == activity.data["to"]
+    end
   end
 
   describe "prepare outgoing" do