Only need to validate a follow request is generated for now
[akkoma] / test / pleroma / web / activity_pub / mrf / followbot_policy_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.FollowbotPolicyTest do
6 use Pleroma.DataCase, async: true
7
8 alias Pleroma.User
9 alias Pleroma.Web.ActivityPub.MRF.FollowbotPolicy
10
11 import Pleroma.Factory
12
13 describe "FollowBotPolicy" do
14 test "follows remote users" do
15 bot = insert(:user, actor_type: "Service")
16 remote_user = insert(:user, local: false)
17 clear_config([:mrf_follow_bot, :follower_nickname], bot.nickname)
18
19 message = %{
20 "@context" => "https://www.w3.org/ns/activitystreams",
21 "to" => [remote_user.follower_address],
22 "cc" => ["https://www.w3.org/ns/activitystreams#Public"],
23 "type" => "Create",
24 "object" => %{
25 "content" => "Test post",
26 "type" => "Note",
27 "attributedTo" => remote_user.ap_id,
28 "inReplyTo" => nil
29 },
30 "actor" => remote_user.ap_id
31 }
32
33 refute User.following?(bot, remote_user)
34
35 assert User.get_follow_requests(remote_user) |> length == 0
36
37 FollowbotPolicy.filter(message)
38
39 assert User.get_follow_requests(remote_user) |> length == 1
40 end
41 end
42 end