1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do
9 import Pleroma.Web.ActivityPub.MRF.HellthreadPolicy
15 "actor" => user.ap_id,
16 "cc" => [user.follower_address],
19 "https://www.w3.org/ns/activitystreams#Public",
20 "https://instance.tld/users/user1",
21 "https://instance.tld/users/user2",
22 "https://instance.tld/users/user3"
29 [user: user, message: message]
32 setup do: clear_config(:mrf_hellthread)
35 test "rejects the message if the recipient count is above reject_threshold", %{
38 clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2})
40 assert {:reject, "[HellthreadPolicy] 3 recipients is over the limit of 2"} ==
44 test "does not reject the message if the recipient count is below reject_threshold", %{
47 clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3})
49 assert {:ok, ^message} = filter(message)
54 test "delists the message if the recipient count is above delist_threshold", %{
58 clear_config([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0})
60 {:ok, message} = filter(message)
61 assert user.follower_address in message["to"]
62 assert "https://www.w3.org/ns/activitystreams#Public" in message["cc"]
65 test "does not delist the message if the recipient count is below delist_threshold", %{
68 clear_config([:mrf_hellthread], %{delist_threshold: 4, reject_threshold: 0})
70 assert {:ok, ^message} = filter(message)
74 test "excludes follower collection and public URI from threshold count", %{message: message} do
75 clear_config([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3})
77 assert {:ok, ^message} = filter(message)