Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into remake-remodel-dms
[akkoma] / test / web / activity_pub / object_validator_test.exs
index e416e080823e566def799568e810d312aa3e3a84..bc2317e557b2169eeec1ca2391c2dce601b93339 100644 (file)
@@ -1,11 +1,11 @@
 defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
   use Pleroma.DataCase
 
+  alias Pleroma.Web.ActivityPub.Builder
   alias Pleroma.Web.ActivityPub.ObjectValidator
   alias Pleroma.Web.ActivityPub.ObjectValidators.LikeValidator
   alias Pleroma.Web.ActivityPub.Utils
   alias Pleroma.Web.CommonAPI
-  alias Pleroma.Web.ActivityPub.Builder
 
   import Pleroma.Factory
 
@@ -15,13 +15,15 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
       user = insert(:user)
       recipient = insert(:user, local: false)
 
-      {:ok, valid_chat_message, _} = Builder.chat_message(user, recipient.ap_id, "hey")
+      {:ok, valid_chat_message, _} = Builder.chat_message(user, recipient.ap_id, "hey :firefox:")
 
       %{user: user, recipient: recipient, valid_chat_message: valid_chat_message}
     end
 
     test "validates for a basic object we build", %{valid_chat_message: valid_chat_message} do
-      assert {:ok, _object, _meta} = ObjectValidator.validate(valid_chat_message, [])
+      assert {:ok, object, _meta} = ObjectValidator.validate(valid_chat_message, [])
+
+      assert object == valid_chat_message
     end
 
     test "does not validate if the message is longer than the remote_limit", %{
@@ -31,6 +33,15 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidatorTest do
       refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, []))
     end
 
+    test "does not validate if the recipient is blocking the actor", %{
+      valid_chat_message: valid_chat_message,
+      user: user,
+      recipient: recipient
+    } do
+      Pleroma.User.block(recipient, user)
+      refute match?({:ok, _object, _meta}, ObjectValidator.validate(valid_chat_message, []))
+    end
+
     test "does not validate if the actor or the recipient is not in our system", %{
       valid_chat_message: valid_chat_message
     } do