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.RejectNonPublicTest do
9 alias Pleroma.Web.ActivityPub.MRF.RejectNonPublic
11 setup do: clear_config([:mrf_rejectnonpublic])
13 describe "public message" do
14 test "it's allowed when address is public" do
15 actor = insert(:user, follower_address: "test-address")
18 "actor" => actor.ap_id,
19 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
20 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
24 assert {:ok, _message} = RejectNonPublic.filter(message)
27 test "it's allowed when cc address contain public address" do
28 actor = insert(:user, follower_address: "test-address")
31 "actor" => actor.ap_id,
32 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
33 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
37 assert {:ok, _message} = RejectNonPublic.filter(message)
41 describe "followers message" do
42 test "it's allowed when addrer of message in the follower addresses of user and it enabled in config" do
43 actor = insert(:user, follower_address: "test-address")
46 "actor" => actor.ap_id,
47 "to" => ["test-address"],
48 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
52 Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], true)
53 assert {:ok, _message} = RejectNonPublic.filter(message)
56 test "it's rejected when addrer of message in the follower addresses of user and it disabled in config" do
57 actor = insert(:user, follower_address: "test-address")
60 "actor" => actor.ap_id,
61 "to" => ["test-address"],
62 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
66 Pleroma.Config.put([:mrf_rejectnonpublic, :allow_followersonly], false)
67 assert {:reject, _} = RejectNonPublic.filter(message)
71 describe "direct message" do
72 test "it's allows when direct messages are allow" do
76 "actor" => actor.ap_id,
77 "to" => ["https://www.w3.org/ns/activitystreams#Publid"],
78 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
82 Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], true)
83 assert {:ok, _message} = RejectNonPublic.filter(message)
86 test "it's reject when direct messages aren't allow" do
90 "actor" => actor.ap_id,
91 "to" => ["https://www.w3.org/ns/activitystreams#Publid~~~"],
92 "cc" => ["https://www.w3.org/ns/activitystreams#Publid"],
96 Pleroma.Config.put([:mrf_rejectnonpublic, :allow_direct], false)
97 assert {:reject, _} = RejectNonPublic.filter(message)