Use Jason instead of Poison in tests

This commit is contained in:
Mark Felder 2020-11-23 13:28:55 -06:00
parent 1ab61953db
commit 3283d0805f
21 changed files with 82 additions and 82 deletions

View File

@ -431,7 +431,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
describe "/inbox" do describe "/inbox" do
test "it inserts an incoming activity into the database", %{conn: conn} do test "it inserts an incoming activity into the database", %{conn: conn} do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
conn = conn =
conn conn
@ -459,7 +459,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
data = data =
File.read!("test/fixtures/mastodon-post-activity.json") File.read!("test/fixtures/mastodon-post-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", user.ap_id) |> Map.put("actor", user.ap_id)
|> put_in(["object", "attridbutedTo"], user.ap_id) |> put_in(["object", "attridbutedTo"], user.ap_id)
@ -476,7 +476,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
end end
test "it clears `unreachable` federation status of the sender", %{conn: conn} do test "it clears `unreachable` federation status of the sender", %{conn: conn} do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
sender_url = data["actor"] sender_url = data["actor"]
Instances.set_consistently_unreachable(sender_url) Instances.set_consistently_unreachable(sender_url)
@ -534,8 +534,8 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
test "without valid signature, " <> test "without valid signature, " <>
"it only accepts Create activities and requires enabled federation", "it only accepts Create activities and requires enabled federation",
%{conn: conn} do %{conn: conn} do
data = File.read!("test/fixtures/mastodon-post-activity.json") |> Poison.decode!() data = File.read!("test/fixtures/mastodon-post-activity.json") |> Jason.decode!()
non_create_data = File.read!("test/fixtures/mastodon-announce.json") |> Poison.decode!() non_create_data = File.read!("test/fixtures/mastodon-announce.json") |> Jason.decode!()
conn = put_req_header(conn, "content-type", "application/activity+json") conn = put_req_header(conn, "content-type", "application/activity+json")
@ -564,7 +564,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
setup do setup do
data = data =
File.read!("test/fixtures/mastodon-post-activity.json") File.read!("test/fixtures/mastodon-post-activity.json")
|> Poison.decode!() |> Jason.decode!()
[data: data] [data: data]
end end
@ -747,7 +747,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubControllerTest do
data = data =
File.read!("test/fixtures/activitypub-client-post-activity.json") File.read!("test/fixtures/activitypub-client-post-activity.json")
|> Poison.decode!() |> Jason.decode!()
object = Map.put(data["object"], "attributedTo", actor.ap_id) object = Map.put(data["object"], "attributedTo", actor.ap_id)

View File

@ -22,7 +22,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do
defp get_old_message do defp get_old_message do
File.read!("test/fixtures/mastodon-post-activity.json") File.read!("test/fixtures/mastodon-post-activity.json")
|> Poison.decode!() |> Jason.decode!()
end end
defp get_new_message do defp get_new_message do

View File

@ -22,7 +22,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
accept_data = accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json") File.read!("test/fixtures/mastodon-accept-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", followed.ap_id) |> Map.put("actor", followed.ap_id)
object = object =
@ -52,7 +52,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
accept_data = accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json") File.read!("test/fixtures/mastodon-accept-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", followed.ap_id) |> Map.put("actor", followed.ap_id)
|> Map.put("object", follow_activity.data["id"]) |> Map.put("object", follow_activity.data["id"])
@ -76,7 +76,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AcceptHandlingTest do
accept_data = accept_data =
File.read!("test/fixtures/mastodon-accept-activity.json") File.read!("test/fixtures/mastodon-accept-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", followed.ap_id) |> Map.put("actor", followed.ap_id)
accept_data = accept_data =

View File

@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
end end
test "it works for incoming announces with actor being inlined (kroeg)" do test "it works for incoming announces with actor being inlined (kroeg)" do
data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Poison.decode!() data = File.read!("test/fixtures/kroeg-announce-with-inline-actor.json") |> Jason.decode!()
_user = insert(:user, local: false, ap_id: data["actor"]["id"]) _user = insert(:user, local: false, ap_id: data["actor"]["id"])
other_user = insert(:user) other_user = insert(:user)
@ -55,7 +55,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
test "it works for incoming announces, fetching the announced object" do test "it works for incoming announces, fetching the announced object" do
data = data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", "http://mastodon.example.org/users/admin/statuses/99541947525187367") |> Map.put("object", "http://mastodon.example.org/users/admin/statuses/99541947525187367")
Tesla.Mock.mock(fn Tesla.Mock.mock(fn
@ -90,7 +90,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_user = insert(:user, local: false, ap_id: data["actor"]) _user = insert(:user, local: false, ap_id: data["actor"])
@ -113,7 +113,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
test "it works for incoming announces with an inlined activity" do test "it works for incoming announces with an inlined activity" do
data = data =
File.read!("test/fixtures/mastodon-announce-private.json") File.read!("test/fixtures/mastodon-announce-private.json")
|> Poison.decode!() |> Jason.decode!()
_user = _user =
insert(:user, insert(:user,
@ -144,7 +144,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
data = data =
File.read!("test/fixtures/bogus-mastodon-announce.json") File.read!("test/fixtures/bogus-mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
_user = insert(:user, local: false, ap_id: data["actor"]) _user = insert(:user, local: false, ap_id: data["actor"])
@ -157,7 +157,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnnounceHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", Object.normalize(activity).data["id"]) |> Map.put("object", Object.normalize(activity).data["id"])
|> Map.put("to", ["http://mastodon.example.org/users/admin/followers"]) |> Map.put("to", ["http://mastodon.example.org/users/admin/followers"])
|> Map.put("cc", []) |> Map.put("cc", [])

View File

@ -31,7 +31,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-vote.json") File.read!("test/fixtures/mastodon-vote.json")
|> Poison.decode!() |> Jason.decode!()
|> Kernel.put_in(["to"], user.ap_id) |> Kernel.put_in(["to"], user.ap_id)
|> Kernel.put_in(["object", "inReplyTo"], object.data["id"]) |> Kernel.put_in(["object", "inReplyTo"], object.data["id"])
|> Kernel.put_in(["object", "to"], user.ap_id) |> Kernel.put_in(["object", "to"], user.ap_id)
@ -66,7 +66,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AnswerHandlingTest do
# TODO: Replace with CommonAPI vote creation when implemented # TODO: Replace with CommonAPI vote creation when implemented
data = data =
File.read!("test/fixtures/mastodon-vote.json") File.read!("test/fixtures/mastodon-vote.json")
|> Poison.decode!() |> Jason.decode!()
|> Kernel.put_in(["to"], user.ap_id) |> Kernel.put_in(["to"], user.ap_id)
|> Kernel.put_in(["object", "inReplyTo"], poll_object.data["id"]) |> Kernel.put_in(["object", "inReplyTo"], poll_object.data["id"])
|> Kernel.put_in(["object", "to"], user.ap_id) |> Kernel.put_in(["object", "to"], user.ap_id)

View File

@ -53,7 +53,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.AudioHandlingTest do
} }
end) end)
data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Poison.decode!() data = File.read!("test/fixtures/tesla_mock/funkwhale_create_audio.json") |> Jason.decode!()
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data) {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)

View File

@ -16,7 +16,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.BlockHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-block-activity.json") File.read!("test/fixtures/mastodon-block-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
blocker = insert(:user, ap_id: data["actor"]) blocker = insert(:user, ap_id: data["actor"])
@ -36,7 +36,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.BlockHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-block-activity.json") File.read!("test/fixtures/mastodon-block-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", blocked.ap_id) |> Map.put("object", blocked.ap_id)
|> Map.put("actor", blocker.ap_id) |> Map.put("actor", blocker.ap_id)

View File

@ -53,7 +53,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
test "it rejects messages that don't contain content" do test "it rejects messages that don't contain content" do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
object = object =
data["object"] data["object"]
@ -79,7 +79,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
test "it rejects messages that don't concern local users" do test "it rejects messages that don't concern local users" do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
_author = _author =
insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now()) insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now())
@ -97,7 +97,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
test "it rejects messages where the `to` field of activity and object don't match" do test "it rejects messages where the `to` field of activity and object don't match" do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
author = insert(:user, ap_id: data["actor"]) author = insert(:user, ap_id: data["actor"])
_recipient = insert(:user, ap_id: List.first(data["to"])) _recipient = insert(:user, ap_id: List.first(data["to"]))
@ -115,7 +115,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", "http://mastodon.example.org/users/admin") |> Map.put("actor", "http://mastodon.example.org/users/admin")
|> put_in(["object", "actor"], "http://mastodon.example.org/users/admin") |> put_in(["object", "actor"], "http://mastodon.example.org/users/admin")
@ -127,7 +127,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
test "it doesn't work for deactivated users" do test "it doesn't work for deactivated users" do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
_author = _author =
insert(:user, insert(:user,
@ -145,7 +145,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do
test "it inserts it and creates a chat" do test "it inserts it and creates a chat" do
data = data =
File.read!("test/fixtures/create-chat-message.json") File.read!("test/fixtures/create-chat-message.json")
|> Poison.decode!() |> Jason.decode!()
author = author =
insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now()) insert(:user, ap_id: data["actor"], local: false, last_refreshed_at: DateTime.utc_now())

View File

@ -25,7 +25,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-delete.json") File.read!("test/fixtures/mastodon-delete.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", deleting_user.ap_id) |> Map.put("actor", deleting_user.ap_id)
|> put_in(["object", "id"], activity.data["object"]) |> put_in(["object", "id"], activity.data["object"])
@ -57,7 +57,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-delete.json") File.read!("test/fixtures/mastodon-delete.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", deleting_user.ap_id) |> Map.put("actor", deleting_user.ap_id)
|> put_in(["object", "id"], activity.data["object"]) |> put_in(["object", "id"], activity.data["object"])
@ -78,7 +78,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-delete.json") File.read!("test/fixtures/mastodon-delete.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", ap_id) |> Map.put("actor", ap_id)
|> put_in(["object", "id"], activity.data["object"]) |> put_in(["object", "id"], activity.data["object"])
@ -91,7 +91,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-delete-user.json") File.read!("test/fixtures/mastodon-delete-user.json")
|> Poison.decode!() |> Jason.decode!()
{:ok, _} = Transmogrifier.handle_incoming(data) {:ok, _} = Transmogrifier.handle_incoming(data)
ObanHelpers.perform_all() ObanHelpers.perform_all()
@ -104,7 +104,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.DeleteHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-delete-user.json") File.read!("test/fixtures/mastodon-delete-user.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", ap_id) |> Map.put("actor", ap_id)
assert match?({:error, _}, Transmogrifier.handle_incoming(data)) assert match?({:error, _}, Transmogrifier.handle_incoming(data))

View File

@ -19,7 +19,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
data = data =
File.read!("test/fixtures/emoji-reaction.json") File.read!("test/fixtures/emoji-reaction.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id) |> Map.put("actor", other_user.ap_id)
@ -44,7 +44,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
data = data =
File.read!("test/fixtures/emoji-reaction-too-long.json") File.read!("test/fixtures/emoji-reaction-too-long.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id) |> Map.put("actor", other_user.ap_id)
@ -52,7 +52,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.EmojiReactHandlingTest do
data = data =
File.read!("test/fixtures/emoji-reaction-no-emoji.json") File.read!("test/fixtures/emoji-reaction-no-emoji.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
|> Map.put("actor", other_user.ap_id) |> Map.put("actor", other_user.ap_id)

View File

@ -28,7 +28,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/osada-follow-activity.json") File.read!("test/fixtures/osada-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
@ -47,7 +47,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false} = activity} = Transmogrifier.handle_incoming(data)
@ -69,7 +69,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
@ -100,7 +100,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)
@ -116,7 +116,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("id", String.replace(data["id"], "2", "3")) |> Map.put("id", String.replace(data["id"], "2", "3"))
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
@ -142,7 +142,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: %{"id" => id}}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: %{"id" => id}}} = Transmogrifier.handle_incoming(data)
@ -157,7 +157,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
with_mock Pleroma.User, [:passthrough], follow: fn _, _, _ -> {:error, :testing} end do with_mock Pleroma.User, [:passthrough], follow: fn _, _, _ -> {:error, :testing} end do
@ -174,7 +174,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/hubzilla-follow-activity.json") File.read!("test/fixtures/hubzilla-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
|> Utils.normalize_params() |> Utils.normalize_params()
@ -192,7 +192,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.FollowHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)

View File

@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-like.json") File.read!("test/fixtures/mastodon-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_actor = insert(:user, ap_id: data["actor"], local: false) _actor = insert(:user, ap_id: data["actor"], local: false)
@ -40,7 +40,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
data = data =
File.read!("test/fixtures/misskey-like.json") File.read!("test/fixtures/misskey-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_actor = insert(:user, ap_id: data["actor"], local: false) _actor = insert(:user, ap_id: data["actor"], local: false)
@ -61,7 +61,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.LikeHandlingTest do
data = data =
File.read!("test/fixtures/misskey-like.json") File.read!("test/fixtures/misskey-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
|> Map.put("_misskey_reaction", "") |> Map.put("_misskey_reaction", "")

View File

@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
end end
test "Mastodon Question activity" do test "Mastodon Question activity" do
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!() data = File.read!("test/fixtures/mastodon-question-activity.json") |> Jason.decode!()
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data) {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
@ -97,7 +97,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-question-activity.json") File.read!("test/fixtures/mastodon-question-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Kernel.put_in(["object", "oneOf"], options) |> Kernel.put_in(["object", "oneOf"], options)
{:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data) {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
@ -142,7 +142,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-question-activity.json") File.read!("test/fixtures/mastodon-question-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Kernel.put_in(["object", "oneOf"], options) |> Kernel.put_in(["object", "oneOf"], options)
|> Kernel.put_in(["object", "tag"], tag) |> Kernel.put_in(["object", "tag"], tag)
@ -158,7 +158,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
end end
test "returns same activity if received a second time" do test "returns same activity if received a second time" do
data = File.read!("test/fixtures/mastodon-question-activity.json") |> Poison.decode!() data = File.read!("test/fixtures/mastodon-question-activity.json") |> Jason.decode!()
assert {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data) assert {:ok, %Activity{local: false} = activity} = Transmogrifier.handle_incoming(data)
@ -168,7 +168,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.QuestionHandlingTest do
test "accepts a Question with no content" do test "accepts a Question with no content" do
data = data =
File.read!("test/fixtures/mastodon-question-activity.json") File.read!("test/fixtures/mastodon-question-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Kernel.put_in(["object", "content"], "") |> Kernel.put_in(["object", "content"], "")
assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data) assert {:ok, %Activity{local: false}} = Transmogrifier.handle_incoming(data)

View File

@ -18,7 +18,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
accept_data = accept_data =
File.read!("test/fixtures/mastodon-reject-activity.json") File.read!("test/fixtures/mastodon-reject-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", followed.ap_id) |> Map.put("actor", followed.ap_id)
accept_data = accept_data =
@ -42,7 +42,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
reject_data = reject_data =
File.read!("test/fixtures/mastodon-reject-activity.json") File.read!("test/fixtures/mastodon-reject-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", followed.ap_id) |> Map.put("actor", followed.ap_id)
|> Map.put("object", follow_activity.data["id"]) |> Map.put("object", follow_activity.data["id"])
@ -58,7 +58,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.RejectHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
|> Map.put("id", "") |> Map.put("id", "")

View File

@ -21,7 +21,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-undo-like.json") File.read!("test/fixtures/mastodon-undo-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", reaction_activity.data["id"]) |> Map.put("object", reaction_activity.data["id"])
|> Map.put("actor", user.ap_id) |> Map.put("actor", user.ap_id)
@ -38,7 +38,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-undo-like.json") File.read!("test/fixtures/mastodon-undo-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
assert Transmogrifier.handle_incoming(data) == :error assert Transmogrifier.handle_incoming(data) == :error
@ -50,7 +50,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
like_data = like_data =
File.read!("test/fixtures/mastodon-like.json") File.read!("test/fixtures/mastodon-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_liker = insert(:user, ap_id: like_data["actor"], local: false) _liker = insert(:user, ap_id: like_data["actor"], local: false)
@ -59,7 +59,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-undo-like.json") File.read!("test/fixtures/mastodon-undo-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", like_data) |> Map.put("object", like_data)
|> Map.put("actor", like_data["actor"]) |> Map.put("actor", like_data["actor"])
@ -81,7 +81,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
like_data = like_data =
File.read!("test/fixtures/mastodon-like.json") File.read!("test/fixtures/mastodon-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_liker = insert(:user, ap_id: like_data["actor"], local: false) _liker = insert(:user, ap_id: like_data["actor"], local: false)
@ -90,7 +90,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-undo-like.json") File.read!("test/fixtures/mastodon-undo-like.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", like_data["id"]) |> Map.put("object", like_data["id"])
|> Map.put("actor", like_data["actor"]) |> Map.put("actor", like_data["actor"])
@ -108,7 +108,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
announce_data = announce_data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
_announcer = insert(:user, ap_id: announce_data["actor"], local: false) _announcer = insert(:user, ap_id: announce_data["actor"], local: false)
@ -118,7 +118,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-undo-announce.json") File.read!("test/fixtures/mastodon-undo-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", announce_data) |> Map.put("object", announce_data)
|> Map.put("actor", announce_data["actor"]) |> Map.put("actor", announce_data["actor"])
@ -135,7 +135,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
follow_data = follow_data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
_follower = insert(:user, ap_id: follow_data["actor"], local: false) _follower = insert(:user, ap_id: follow_data["actor"], local: false)
@ -144,7 +144,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-unfollow-activity.json") File.read!("test/fixtures/mastodon-unfollow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", follow_data) |> Map.put("object", follow_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
@ -162,7 +162,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
block_data = block_data =
File.read!("test/fixtures/mastodon-block-activity.json") File.read!("test/fixtures/mastodon-block-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
_blocker = insert(:user, ap_id: block_data["actor"], local: false) _blocker = insert(:user, ap_id: block_data["actor"], local: false)
@ -171,7 +171,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UndoHandlingTest do
data = data =
File.read!("test/fixtures/mastodon-unblock-activity.json") File.read!("test/fixtures/mastodon-unblock-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", block_data) |> Map.put("object", block_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)

View File

@ -14,7 +14,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
test "it works for incoming update activities" do test "it works for incoming update activities" do
user = insert(:user, local: false) user = insert(:user, local: false)
update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!() update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object = object =
update_data["object"] update_data["object"]
@ -58,7 +58,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
{:ok, _activity} = {:ok, _activity} =
"test/fixtures/mastodon-update.json" "test/fixtures/mastodon-update.json"
|> File.read!() |> File.read!()
|> Poison.decode!() |> Jason.decode!()
|> Map.put("actor", actor) |> Map.put("actor", actor)
|> Map.update!("object", fn object -> |> Map.update!("object", fn object ->
object object
@ -82,7 +82,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
assert user.fields == [] assert user.fields == []
update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!() update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object = object =
update_data["object"] update_data["object"]
@ -138,7 +138,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.UserUpdateHandlingTest do
test "it works for incoming update activities which lock the account" do test "it works for incoming update activities which lock the account" do
user = insert(:user, local: false) user = insert(:user, local: false)
update_data = File.read!("test/fixtures/mastodon-update.json") |> Poison.decode!() update_data = File.read!("test/fixtures/mastodon-update.json") |> Jason.decode!()
object = object =
update_data["object"] update_data["object"]

View File

@ -31,14 +31,14 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
follow_data = follow_data =
File.read!("test/fixtures/mastodon-follow-activity.json") File.read!("test/fixtures/mastodon-follow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", user.ap_id) |> Map.put("object", user.ap_id)
{:ok, %Activity{data: _, local: false}} = Transmogrifier.handle_incoming(follow_data) {:ok, %Activity{data: _, local: false}} = Transmogrifier.handle_incoming(follow_data)
data = data =
File.read!("test/fixtures/mastodon-unfollow-activity.json") File.read!("test/fixtures/mastodon-unfollow-activity.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", follow_data) |> Map.put("object", follow_data)
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data) {:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)

View File

@ -164,7 +164,7 @@ defmodule Pleroma.Web.FederatorTest do
params = params =
File.read!("test/fixtures/mastodon-post-activity.json") File.read!("test/fixtures/mastodon-post-activity.json")
|> Poison.decode!() |> Jason.decode!()
assert {:ok, job} = Federator.incoming_ap_doc(params) assert {:ok, job} = Federator.incoming_ap_doc(params)
assert {:error, _} = ObanHelpers.perform(job) assert {:error, _} = ObanHelpers.perform(job)

View File

@ -81,7 +81,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
redirect_query = URI.parse(redirected_to(conn)).query redirect_query = URI.parse(redirected_to(conn)).query
assert %{"state" => state_param} = URI.decode_query(redirect_query) assert %{"state" => state_param} = URI.decode_query(redirect_query)
assert {:ok, state_components} = Poison.decode(state_param) assert {:ok, state_components} = Jason.decode(state_param)
expected_client_id = app.client_id expected_client_id = app.client_id
expected_redirect_uri = app.redirect_uris expected_redirect_uri = app.redirect_uris
@ -115,7 +115,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM", "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs", "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter", "provider" => "twitter",
"state" => Poison.encode!(state_params) "state" => Jason.encode!(state_params)
} }
) )
@ -147,7 +147,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM", "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs", "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter", "provider" => "twitter",
"state" => Poison.encode!(state_params) "state" => Jason.encode!(state_params)
} }
) )
@ -178,7 +178,7 @@ defmodule Pleroma.Web.OAuth.OAuthControllerTest do
"oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM", "oauth_token" => "G-5a3AAAAAAAwMH9AAABaektfSM",
"oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs", "oauth_verifier" => "QZl8vUqNvXMTKpdmUnGejJxuHG75WWWs",
"provider" => "twitter", "provider" => "twitter",
"state" => Poison.encode!(state_params) "state" => Jason.encode!(state_params)
} }
) )

View File

@ -222,7 +222,7 @@ defmodule Pleroma.Web.StreamerTest do
data = data =
File.read!("test/fixtures/mastodon-announce.json") File.read!("test/fixtures/mastodon-announce.json")
|> Poison.decode!() |> Jason.decode!()
|> Map.put("object", activity.data["object"]) |> Map.put("object", activity.data["object"])
|> Map.put("actor", user.ap_id) |> Map.put("actor", user.ap_id)

View File

@ -85,8 +85,8 @@ defmodule Pleroma.Tests.Helpers do
assigns = Map.new(assigns) assigns = Map.new(assigns)
view.render(template, assigns) view.render(template, assigns)
|> Poison.encode!() |> Jason.encode!()
|> Poison.decode!() |> Jason.decode!()
end end
def stringify_keys(nil), do: nil def stringify_keys(nil), do: nil