1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.VocabularyPolicyTest do
8 alias Pleroma.Web.ActivityPub.MRF.VocabularyPolicy
11 setup do: clear_config([:mrf_vocabulary, :accept])
13 test "it accepts based on parent activity type" do
14 Pleroma.Config.put([:mrf_vocabulary, :accept], ["Like"])
18 "object" => "whatever"
21 {:ok, ^message} = VocabularyPolicy.filter(message)
24 test "it accepts based on child object type" do
25 Pleroma.Config.put([:mrf_vocabulary, :accept], ["Create", "Note"])
31 "content" => "whatever"
35 {:ok, ^message} = VocabularyPolicy.filter(message)
38 test "it does not accept disallowed child objects" do
39 Pleroma.Config.put([:mrf_vocabulary, :accept], ["Create", "Note"])
45 "content" => "whatever"
49 {:reject, nil} = VocabularyPolicy.filter(message)
52 test "it does not accept disallowed parent types" do
53 Pleroma.Config.put([:mrf_vocabulary, :accept], ["Announce", "Note"])
59 "content" => "whatever"
63 {:reject, nil} = VocabularyPolicy.filter(message)
68 setup do: clear_config([:mrf_vocabulary, :reject])
70 test "it rejects based on parent activity type" do
71 Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"])
75 "object" => "whatever"
78 {:reject, nil} = VocabularyPolicy.filter(message)
81 test "it rejects based on child object type" do
82 Pleroma.Config.put([:mrf_vocabulary, :reject], ["Note"])
88 "content" => "whatever"
92 {:reject, nil} = VocabularyPolicy.filter(message)
95 test "it passes through objects that aren't disallowed" do
96 Pleroma.Config.put([:mrf_vocabulary, :reject], ["Like"])
100 "object" => "whatever"
103 {:ok, ^message} = VocabularyPolicy.filter(message)