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.AntiFollowbotPolicyTest do
9 alias Pleroma.Web.ActivityPub.MRF.AntiFollowbotPolicy
11 describe "blocking based on attributes" do
12 test "matches followbots by nickname" do
13 actor = insert(:user, %{nickname: "followbot@example.com"})
14 target = insert(:user)
17 "@context" => "https://www.w3.org/ns/activitystreams",
19 "actor" => actor.ap_id,
20 "object" => target.ap_id,
21 "id" => "https://example.com/activities/1234"
24 {:reject, nil} = AntiFollowbotPolicy.filter(message)
27 test "matches followbots by display name" do
28 actor = insert(:user, %{name: "Federation Bot"})
29 target = insert(:user)
32 "@context" => "https://www.w3.org/ns/activitystreams",
34 "actor" => actor.ap_id,
35 "object" => target.ap_id,
36 "id" => "https://example.com/activities/1234"
39 {:reject, nil} = AntiFollowbotPolicy.filter(message)
43 test "it allows non-followbots" do
45 target = insert(:user)
48 "@context" => "https://www.w3.org/ns/activitystreams",
50 "actor" => actor.ap_id,
51 "object" => target.ap_id,
52 "id" => "https://example.com/activities/1234"
55 {:ok, _} = AntiFollowbotPolicy.filter(message)
58 test "it gracefully handles nil display names" do
59 actor = insert(:user, %{name: nil})
60 target = insert(:user)
63 "@context" => "https://www.w3.org/ns/activitystreams",
65 "actor" => actor.ap_id,
66 "object" => target.ap_id,
67 "id" => "https://example.com/activities/1234"
70 {:ok, _} = AntiFollowbotPolicy.filter(message)