logo

pleroma

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

user_allowlist_policy_test.exs (1157B)


  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.UserAllowListPolicyTest do
  5. use Pleroma.DataCase
  6. import Pleroma.Factory
  7. alias Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy
  8. setup do: clear_config(:mrf_user_allowlist)
  9. test "pass filter if allow list is empty" do
  10. actor = insert(:user)
  11. message = %{"actor" => actor.ap_id}
  12. assert UserAllowListPolicy.filter(message) == {:ok, message}
  13. end
  14. test "pass filter if allow list isn't empty and user in allow list" do
  15. actor = insert(:user)
  16. Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => [actor.ap_id, "test-ap-id"]})
  17. message = %{"actor" => actor.ap_id}
  18. assert UserAllowListPolicy.filter(message) == {:ok, message}
  19. end
  20. test "rejected if allow list isn't empty and user not in allow list" do
  21. actor = insert(:user)
  22. Pleroma.Config.put([:mrf_user_allowlist], %{"localhost" => ["test-ap-id"]})
  23. message = %{"actor" => actor.ap_id}
  24. assert {:reject, _} = UserAllowListPolicy.filter(message)
  25. end
  26. end