Fix MRF policies to also work with Update
[akkoma] / test / pleroma / web / activity_pub / mrf / subchain_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.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 setup do: clear_config([:mrf_subchain, :match_actor])
17
18 test "it matches and processes subchains when the actor matches a configured target" do
19 clear_config([:mrf_subchain, :match_actor], %{
20 ~r/^https:\/\/banned.com/s => [DropPolicy]
21 })
22
23 {:reject, _} = SubchainPolicy.filter(@message)
24 end
25
26 test "it doesn't match and process subchains when the actor doesn't match a configured target" do
27 clear_config([:mrf_subchain, :match_actor], %{
28 ~r/^https:\/\/borked.com/s => [DropPolicy]
29 })
30
31 {:ok, _message} = SubchainPolicy.filter(@message)
32 end
33 end