1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.MentionPolicyTest do
8 alias Pleroma.Web.ActivityPub.MRF.MentionPolicy
10 clear_config(:mrf_mention)
12 test "pass filter if allow list is empty" do
13 Pleroma.Config.delete([:mrf_mention])
17 "to" => ["https://example.com/ok"],
18 "cc" => ["https://example.com/blocked"]
21 assert MentionPolicy.filter(message) == {:ok, message}
26 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
32 assert MentionPolicy.filter(message) == {:ok, message}
36 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
40 "to" => ["https://example.com/ok"]
43 assert MentionPolicy.filter(message) == {:ok, message}
47 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
51 "cc" => ["https://example.com/ok"]
54 assert MentionPolicy.filter(message) == {:ok, message}
58 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
62 "to" => ["https://example.com/ok"],
63 "cc" => ["https://example.com/ok2"]
66 assert MentionPolicy.filter(message) == {:ok, message}
72 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
76 "to" => ["https://example.com/blocked"]
79 assert MentionPolicy.filter(message) == {:reject, nil}
83 Pleroma.Config.put([:mrf_mention], %{actors: ["https://example.com/blocked"]})
87 "to" => ["https://example.com/ok"],
88 "cc" => ["https://example.com/blocked"]
91 assert MentionPolicy.filter(message) == {:reject, nil}