diff options
author | kaniini <ariadne@dereferenced.org> | 2019-10-23 00:47:28 +0000 |
---|---|---|
committer | kaniini <ariadne@dereferenced.org> | 2019-10-23 00:47:28 +0000 |
commit | 894fb806e9b92a55f2eeb8b450735b66fa4eb479 (patch) | |
tree | 55616308006b0d267b64bc847260f5df490193b7 | |
parent | 6281e4795a51034f026aeb833093e47b47255799 (diff) | |
parent | 277aea45b9799596c4144b80b9e77e2801d9becd (diff) | |
download | pleroma-894fb806e9b92a55f2eeb8b450735b66fa4eb479.tar.gz |
Merge branch 'chore/add-single-value-deserialization-tests' into 'develop'
tests: transmogrifier: add explicit regression tests for JSON-LD strings as single-element array fuckery
See merge request pleroma/pleroma!1873
-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 |