1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.NoEmptyPolicyTest do
7 alias Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy
9 setup_all do: clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.NoEmptyPolicy])
11 test "Notes with content are exempt" do
13 "actor" => "http://localhost:4001/users/testuser",
14 "cc" => ["http://localhost:4001/users/testuser/followers"],
16 "actor" => "http://localhost:4001/users/testuser",
18 "cc" => ["http://localhost:4001/users/testuser/followers"],
19 "source" => "this is a test post",
20 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
23 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
27 assert NoEmptyPolicy.filter(message) == {:ok, message}
30 test "Polls are exempt" do
32 "actor" => "http://localhost:4001/users/testuser",
33 "cc" => ["http://localhost:4001/users/testuser/followers"],
35 "actor" => "http://localhost:4001/users/testuser",
37 "cc" => ["http://localhost:4001/users/testuser/followers"],
40 "name" => "chocolate",
41 "replies" => %{"totalItems" => 0, "type" => "Collection"},
46 "replies" => %{"totalItems" => 0, "type" => "Collection"},
52 "https://www.w3.org/ns/activitystreams#Public",
53 "http://localhost:4001/users/user2"
58 "https://www.w3.org/ns/activitystreams#Public",
59 "http://localhost:4001/users/user2"
64 assert NoEmptyPolicy.filter(message) == {:ok, message}
67 test "Notes with attachments are exempt" do
69 "actor" => "http://localhost:4001/users/testuser",
70 "cc" => ["http://localhost:4001/users/testuser/followers"],
72 "actor" => "http://localhost:4001/users/testuser",
75 "actor" => "http://localhost:4001/users/testuser",
76 "mediaType" => "image/png",
82 "http://localhost:4001/media/68ba231cf12e1382ce458f1979969f8ed5cc07ba198a02e653464abaf39bdb90.png",
83 "mediaType" => "image/png",
89 "cc" => ["http://localhost:4001/users/testuser/followers"],
92 "https://www.w3.org/ns/activitystreams#Public",
93 "http://localhost:4001/users/user2"
98 "https://www.w3.org/ns/activitystreams#Public",
99 "http://localhost:4001/users/user2"
104 assert NoEmptyPolicy.filter(message) == {:ok, message}
107 test "Notes with only mentions are denied" do
109 "actor" => "http://localhost:4001/users/testuser",
110 "cc" => ["http://localhost:4001/users/testuser/followers"],
112 "actor" => "http://localhost:4001/users/testuser",
114 "cc" => ["http://localhost:4001/users/testuser/followers"],
115 "source" => "@user2",
117 "https://www.w3.org/ns/activitystreams#Public",
118 "http://localhost:4001/users/user2"
123 "https://www.w3.org/ns/activitystreams#Public",
124 "http://localhost:4001/users/user2"
129 assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}
132 test "Notes with no content are denied" do
134 "actor" => "http://localhost:4001/users/testuser",
135 "cc" => ["http://localhost:4001/users/testuser/followers"],
137 "actor" => "http://localhost:4001/users/testuser",
139 "cc" => ["http://localhost:4001/users/testuser/followers"],
142 "https://www.w3.org/ns/activitystreams#Public"
147 "https://www.w3.org/ns/activitystreams#Public"
152 assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}