diff options
| author | lain <lain@soykaf.club> | 2020-04-17 14:23:59 +0200 |
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-04-17 15:37:54 +0200 |
| commit | 372614cfd3119b589c9c47619445714e8ae6c07e (patch) | |
| tree | 5235e88411e86659dd51ed0beb6cfbae0f913ecf /test/web/activity_pub | |
| parent | d45ae6485811189e98f774ecdb46f0ccdfa8b2b3 (diff) | |
| download | pleroma-372614cfd3119b589c9c47619445714e8ae6c07e.tar.gz pleroma-372614cfd3119b589c9c47619445714e8ae6c07e.zip | |
ChatView: Add a mastodon api representation of the recipient.
Diffstat (limited to 'test/web/activity_pub')
| -rw-r--r-- | test/web/activity_pub/transmogrifier/chat_message_test.exs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/web/activity_pub/transmogrifier/chat_message_test.exs b/test/web/activity_pub/transmogrifier/chat_message_test.exs index 7e7f9ebec..4d6f24609 100644 --- a/test/web/activity_pub/transmogrifier/chat_message_test.exs +++ b/test/web/activity_pub/transmogrifier/chat_message_test.exs @@ -8,6 +8,7 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do import Pleroma.Factory alias Pleroma.Activity + alias Pleroma.Chat alias Pleroma.Object alias Pleroma.Web.ActivityPub.Transmogrifier @@ -42,6 +43,21 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do {:error, _} = Transmogrifier.handle_incoming(data) end + test "it rejects messages where the `to` field of activity and object don't match" do + data = + File.read!("test/fixtures/create-chat-message.json") + |> Poison.decode!() + + author = insert(:user, ap_id: data["actor"]) + _recipient = insert(:user, ap_id: List.first(data["to"])) + + data = + data + |> Map.put("to", author.ap_id) + + {:error, _} = Transmogrifier.handle_incoming(data) + end + test "it inserts it and creates a chat" do data = File.read!("test/fixtures/create-chat-message.json") @@ -59,6 +75,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier.ChatMessageTest do assert object assert object.data["content"] == "You expected a cute girl? Too bad. alert('XSS')" + + refute Chat.get(author.id, recipient.ap_id) + assert Chat.get(recipient.id, author.ap_id) end end end |
