logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

subchain_policy_test.exs (1055B)


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