Merge branch 'feature/new-registrations-digest' into 'develop'
[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 clear_config([:mrf_subchain, :match_actor])
18
19 test "it matches and processes subchains when the actor matches a configured target" do
20 Pleroma.Config.put([:mrf_subchain, :match_actor], %{
21 ~r/^https:\/\/banned.com/s => [DropPolicy]
22 })
23
24 {:reject, _} = SubchainPolicy.filter(@message)
25 end
26
27 test "it doesn't match and process subchains when the actor doesn't match a configured target" do
28 Pleroma.Config.put([:mrf_subchain, :match_actor], %{
29 ~r/^https:\/\/borked.com/s => [DropPolicy]
30 })
31
32 {:ok, _message} = SubchainPolicy.filter(@message)
33 end
34 end