Merge branch 'develop' into 'remove-avatar-header'
[akkoma] / test / web / activity_pub / mrf / subchain_policy_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.ActivityPub.MRF.SubchainPolicyTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.Web.ActivityPub.MRF.DropPolicy
9 alias Pleroma.Web.ActivityPub.MRF.SubchainPolicy
10
11 @message %{
12 "actor" => "https://banned.com",
13 "type" => "Create",
14 "object" => %{"content" => "hi"}
15 }
16
17 test "it matches and processes subchains when the actor matches a configured target" do
18 Pleroma.Config.put([:mrf_subchain, :match_actor], %{
19 ~r/^https:\/\/banned.com/s => [DropPolicy]
20 })
21
22 {:reject, _} = SubchainPolicy.filter(@message)
23 end
24
25 test "it doesn't match and process subchains when the actor doesn't match a configured target" do
26 Pleroma.Config.put([:mrf_subchain, :match_actor], %{
27 ~r/^https:\/\/borked.com/s => [DropPolicy]
28 })
29
30 {:ok, _message} = SubchainPolicy.filter(@message)
31 end
32 end