2020-09-07 20:50:37 +00:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-13 06:49:20 +00:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-09-07 20:50:37 +00:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicyTest do
|
2020-12-21 11:21:40 +00:00
|
|
|
use Pleroma.DataCase, async: true
|
2020-09-07 20:50:37 +00:00
|
|
|
import Pleroma.Factory
|
|
|
|
|
2020-09-07 21:18:36 +00:00
|
|
|
alias Pleroma.Web.ActivityPub.MRF.ForceBotUnlistedPolicy
|
2020-09-07 21:28:29 +00:00
|
|
|
@public "https://www.w3.org/ns/activitystreams#Public"
|
2020-09-07 20:50:37 +00:00
|
|
|
|
|
|
|
defp generate_messages(actor) do
|
|
|
|
{%{
|
2020-09-07 20:53:45 +00:00
|
|
|
"actor" => actor.ap_id,
|
|
|
|
"type" => "Create",
|
|
|
|
"object" => %{},
|
|
|
|
"to" => [@public, "f"],
|
|
|
|
"cc" => [actor.follower_address, "d"]
|
|
|
|
},
|
|
|
|
%{
|
|
|
|
"actor" => actor.ap_id,
|
|
|
|
"type" => "Create",
|
|
|
|
"object" => %{"to" => ["f", actor.follower_address], "cc" => ["d", @public]},
|
|
|
|
"to" => ["f", actor.follower_address],
|
|
|
|
"cc" => ["d", @public]
|
|
|
|
}}
|
2020-09-07 20:50:37 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test "removes from the federated timeline by nickname heuristics 1" do
|
|
|
|
actor = insert(:user, %{nickname: "annoying_ebooks@example.com"})
|
|
|
|
|
|
|
|
{message, except_message} = generate_messages(actor)
|
|
|
|
|
|
|
|
assert ForceBotUnlistedPolicy.filter(message) == {:ok, except_message}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "removes from the federated timeline by nickname heuristics 2" do
|
|
|
|
actor = insert(:user, %{nickname: "cirnonewsnetworkbot@meow.cat"})
|
|
|
|
|
|
|
|
{message, except_message} = generate_messages(actor)
|
|
|
|
|
|
|
|
assert ForceBotUnlistedPolicy.filter(message) == {:ok, except_message}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "removes from the federated timeline by actor type Application" do
|
|
|
|
actor = insert(:user, %{actor_type: "Application"})
|
|
|
|
|
|
|
|
{message, except_message} = generate_messages(actor)
|
|
|
|
|
|
|
|
assert ForceBotUnlistedPolicy.filter(message) == {:ok, except_message}
|
|
|
|
end
|
|
|
|
|
|
|
|
test "removes from the federated timeline by actor type Service" do
|
|
|
|
actor = insert(:user, %{actor_type: "Service"})
|
|
|
|
|
|
|
|
{message, except_message} = generate_messages(actor)
|
|
|
|
|
|
|
|
assert ForceBotUnlistedPolicy.filter(message) == {:ok, except_message}
|
|
|
|
end
|
|
|
|
end
|