X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fanti_link_spam_policy_test.exs;h=c3ee03a054f7974e290077c81e9fe27b7476aff1;hb=e3085c495c221b52f40c95a9beab33e51f02d81b;hp=5b990451c238ab673cfab5c9e6b1abb4dfac3c46;hpb=762be6ce10d2145e8e31d42c5d1a0bab93dbe7b0;p=akkoma diff --git a/test/pleroma/web/activity_pub/mrf/anti_link_spam_policy_test.exs b/test/pleroma/web/activity_pub/mrf/anti_link_spam_policy_test.exs index 5b990451c..c3ee03a05 100644 --- a/test/pleroma/web/activity_pub/mrf/anti_link_spam_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/anti_link_spam_policy_test.exs @@ -7,6 +7,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do import Pleroma.Factory import ExUnit.CaptureLog + alias Pleroma.Web.ActivityPub.MRF alias Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy @linkless_message %{ @@ -49,15 +50,39 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do assert user.note_count == 0 + message = %{ + "type" => "Create", + "actor" => user.ap_id, + "object" => %{ + "formerRepresentations" => %{ + "type" => "OrderedCollection", + "orderedItems" => [ + %{ + "content" => "hi world!" + } + ] + }, + "content" => "mew" + } + } + + {:reject, _} = MRF.filter_one(AntiLinkSpamPolicy, message) + end + + test "it allows posts with links for local users" do + user = insert(:user) + + assert user.note_count == 0 + message = @linkful_message |> Map.put("actor", user.ap_id) - {:reject, _} = AntiLinkSpamPolicy.filter(message) + {:ok, _message} = AntiLinkSpamPolicy.filter(message) end - test "it allows posts with links for local users" do - user = insert(:user) + test "it disallows posts with links in history" do + user = insert(:user, local: false) assert user.note_count == 0 @@ -65,7 +90,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do @linkful_message |> Map.put("actor", user.ap_id) - {:ok, _message} = AntiLinkSpamPolicy.filter(message) + {:reject, _} = AntiLinkSpamPolicy.filter(message) end end