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 defmodule Pleroma.Web.ActivityPub.MRF.UserAllowListPolicyTest do
8 alias Pleroma.Web.ActivityPub.MRF.UserAllowListPolicy
11 policy = Pleroma.Config.get([:mrf_user_allowlist]) || []
12 on_exit(fn -> Pleroma.Config.put([:mrf_user_allowlist], policy) end)
17 test "pass filter if allow list is empty" do
19 message = %{"actor" => actor.ap_id}
20 assert UserAllowListPolicy.filter(message) == {:ok, message}
23 test "pass filter if allow list isn't empty and user in allow list" do
25 Pleroma.Config.put([:mrf_user_allowlist, :localhost], [actor.ap_id, "test-ap-id"])
26 message = %{"actor" => actor.ap_id}
27 assert UserAllowListPolicy.filter(message) == {:ok, message}
30 test "rejected if allow list isn't empty and user not in allow list" do
32 Pleroma.Config.put([:mrf_user_allowlist, :localhost], ["test-ap-id"])
33 message = %{"actor" => actor.ap_id}
34 assert UserAllowListPolicy.filter(message) == {:reject, nil}