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
This commit is contained in:
kaniini 2019-10-23 00:47:28 +00:00
commit 894fb806e9
1 changed files with 44 additions and 0 deletions

View File

@ -1106,6 +1106,50 @@ test "it accepts Flag activities" do
assert activity.data["actor"] == other_user.ap_id assert activity.data["actor"] == other_user.ap_id
assert activity.data["cc"] == [user.ap_id] assert activity.data["cc"] == [user.ap_id]
end 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 end
describe "prepare outgoing" do describe "prepare outgoing" do