X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Factivity_pub%2Fmrf%2Fanti_link_spam_policy_test.exs;h=03dc299ecf7fc3d4bb649956c0b35e295b62c1ff;hb=8340fe8fcce15a22e2bef9d5db41ad58c3c009e0;hp=a456e863c9045651bc86d65ae8f6ca0c7783d2c9;hpb=736d8ad6be1ccb1514a189ccf2384e9699ea107e;p=akkoma diff --git a/test/web/activity_pub/mrf/anti_link_spam_policy_test.exs b/test/web/activity_pub/mrf/anti_link_spam_policy_test.exs index a456e863c..03dc299ec 100644 --- a/test/web/activity_pub/mrf/anti_link_spam_policy_test.exs +++ b/test/web/activity_pub/mrf/anti_link_spam_policy_test.exs @@ -5,6 +5,7 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do use Pleroma.DataCase import Pleroma.Factory + import ExUnit.CaptureLog alias Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicy @@ -22,6 +23,14 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do } } + @response_message %{ + "type" => "Create", + "object" => %{ + "name" => "yes", + "type" => "Answer" + } + } + describe "with new user" do test "it allows posts without links" do user = insert(:user) @@ -106,7 +115,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do @linkless_message |> Map.put("actor", "http://invalid.actor") - {:reject, _} = AntiLinkSpamPolicy.filter(message) + assert capture_log(fn -> + {:reject, _} = AntiLinkSpamPolicy.filter(message) + end) =~ "[error] Could not decode user at fetch http://invalid.actor" end test "it rejects posts with links" do @@ -114,7 +125,21 @@ defmodule Pleroma.Web.ActivityPub.MRF.AntiLinkSpamPolicyTest do @linkful_message |> Map.put("actor", "http://invalid.actor") - {:reject, _} = AntiLinkSpamPolicy.filter(message) + assert capture_log(fn -> + {:reject, _} = AntiLinkSpamPolicy.filter(message) + end) =~ "[error] Could not decode user at fetch http://invalid.actor" + end + end + + describe "with contentless-objects" do + test "it does not reject them or error out" do + user = insert(:user, info: %{note_count: 1}) + + message = + @response_message + |> Map.put("actor", user.ap_id) + + {:ok, _message} = AntiLinkSpamPolicy.filter(message) end end end