1 # Pleroma: A lightweight social networking server
2 # Copyright © 2019 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"
26 [user: user, message: message]
29 clear_config(:mrf_hellthread)
32 test "rejects the message if the recipient count is above reject_threshold", %{
35 Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2})
37 {:reject, nil} = filter(message)
40 test "does not reject the message if the recipient count is below reject_threshold", %{
43 Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3})
45 assert {:ok, ^message} = filter(message)
50 test "delists the message if the recipient count is above delist_threshold", %{
54 Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0})
56 {:ok, message} = filter(message)
57 assert user.follower_address in message["to"]
58 assert "https://www.w3.org/ns/activitystreams#Public" in message["cc"]
61 test "does not delist the message if the recipient count is below delist_threshold", %{
64 Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 4, reject_threshold: 0})
66 assert {:ok, ^message} = filter(message)
70 test "excludes follower collection and public URI from threshold count", %{message: message} do
71 Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3})
73 assert {:ok, ^message} = filter(message)