diff options
author | Ariadne Conill <ariadne@dereferenced.org> | 2019-10-22 19:43:31 -0500 |
---|---|---|
committer | Ariadne Conill <ariadne@dereferenced.org> | 2019-10-22 19:43:31 -0500 |
commit | 277aea45b9799596c4144b80b9e77e2801d9becd (patch) | |
tree | 55616308006b0d267b64bc847260f5df490193b7 | |
parent | 6281e4795a51034f026aeb833093e47b47255799 (diff) | |
download | pleroma-277aea45b9799596c4144b80b9e77e2801d9becd.tar.gz pleroma-277aea45b9799596c4144b80b9e77e2801d9becd.zip |
tests: transmogrifier: add explicit regression tests for JSON-LD string to single-element array deserialization
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.
-rw-r--r-- | test/web/activity_pub/transmogrifier_test.exs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier_test.exs b/test/web/activity_pub/transmogrifier_test.exs index dbb6e59b0..77e041b4a 100644 --- a/test/web/activity_pub/transmogrifier_test.exs +++ b/test/web/activity_pub/transmogrifier_test.exs @@ -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 |