aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2020-05-18 18:45:33 +0200
committerlain <lain@soykaf.club>2020-05-18 18:45:33 +0200
commitbe4db41d713f981cc464e5fa7bc7191d3ff776d6 (patch)
tree37104cc234a59700fedc43bdf165bd4e5774cff1 /test
parent0d417e005d5ef89f982866ee09559aef24e36a85 (diff)
downloadpleroma-be4db41d713f981cc464e5fa7bc7191d3ff776d6.tar.gz
ChatMessageValidator: Allow one message in an array, too.
Diffstat (limited to 'test')
-rw-r--r--test/web/activity_pub/object_validator_test.exs35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/web/activity_pub/object_validator_test.exs b/test/web/activity_pub/object_validator_test.exs
index da33d3dbc..a79e50a29 100644
--- a/test/web/activity_pub/object_validator_test.exs
+++ b/test/web/activity_pub/object_validator_test.exs
@@ -13,6 +13,20 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
import Pleroma.Factory
describe "attachments" do
+ test "works with honkerific attachments" do
+ attachment = %{
+ "mediaType" => "image/jpeg",
+ "name" => "298p3RG7j27tfsZ9RQ.jpg",
+ "summary" => "298p3RG7j27tfsZ9RQ.jpg",
+ "type" => "Document",
+ "url" => "https://honk.tedunangst.com/d/298p3RG7j27tfsZ9RQ.jpg"
+ }
+
+ assert {:ok, attachment} =
+ AttachmentValidator.cast_and_validate(attachment)
+ |> Ecto.Changeset.apply_action(:insert)
+ end
+
test "it turns mastodon attachments into our attachments" do
attachment = %{
"url" =>
@@ -103,6 +117,27 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
assert object["attachment"]
end
+ test "validates for a basic object with an attachment in an array", %{
+ valid_chat_message: valid_chat_message,
+ user: user
+ } do
+ file = %Plug.Upload{
+ content_type: "image/jpg",
+ path: Path.absname("test/fixtures/image.jpg"),
+ filename: "an_image.jpg"
+ }
+
+ {:ok, attachment} = ActivityPub.upload(file, actor: user.ap_id)
+
+ valid_chat_message =
+ valid_chat_message
+ |> Map.put("attachment", [attachment.data])
+
+ assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, [])
+
+ assert object["attachment"]
+ end
+
test "validates for a basic object with an attachment but without content", %{
valid_chat_message: valid_chat_message,
user: user