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
10 clear_config([:mrf_user_allowlist, :localhost])
12 test "pass filter if allow list is empty" do
14 message = %{"actor" => actor.ap_id}
15 assert UserAllowListPolicy.filter(message) == {:ok, message}
18 test "pass filter if allow list isn't empty and user in allow list" do
20 Pleroma.Config.put([:mrf_user_allowlist, :localhost], [actor.ap_id, "test-ap-id"])
21 message = %{"actor" => actor.ap_id}
22 assert UserAllowListPolicy.filter(message) == {:ok, message}
25 test "rejected if allow list isn't empty and user not in allow list" do
27 Pleroma.Config.put([:mrf_user_allowlist, :localhost], ["test-ap-id"])
28 message = %{"actor" => actor.ap_id}
29 assert UserAllowListPolicy.filter(message) == {:reject, nil}