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"],
20 "content" => "this is a test post"
22 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
25 "to" => ["https://www.w3.org/ns/activitystreams#Public"],
29 assert NoEmptyPolicy.filter(message) == {:ok, message}
32 test "Polls are exempt" do
34 "actor" => "http://localhost:4001/users/testuser",
35 "cc" => ["http://localhost:4001/users/testuser/followers"],
37 "actor" => "http://localhost:4001/users/testuser",
39 "cc" => ["http://localhost:4001/users/testuser/followers"],
42 "name" => "chocolate",
43 "replies" => %{"totalItems" => 0, "type" => "Collection"},
48 "replies" => %{"totalItems" => 0, "type" => "Collection"},
54 "https://www.w3.org/ns/activitystreams#Public",
55 "http://localhost:4001/users/user2"
60 "https://www.w3.org/ns/activitystreams#Public",
61 "http://localhost:4001/users/user2"
66 assert NoEmptyPolicy.filter(message) == {:ok, message}
69 test "Notes with attachments are exempt" do
71 "actor" => "http://localhost:4001/users/testuser",
72 "cc" => ["http://localhost:4001/users/testuser/followers"],
74 "actor" => "http://localhost:4001/users/testuser",
77 "actor" => "http://localhost:4001/users/testuser",
78 "mediaType" => "image/png",
84 "http://localhost:4001/media/68ba231cf12e1382ce458f1979969f8ed5cc07ba198a02e653464abaf39bdb90.png",
85 "mediaType" => "image/png",
91 "cc" => ["http://localhost:4001/users/testuser/followers"],
94 "https://www.w3.org/ns/activitystreams#Public",
95 "http://localhost:4001/users/user2"
100 "https://www.w3.org/ns/activitystreams#Public",
101 "http://localhost:4001/users/user2"
106 assert NoEmptyPolicy.filter(message) == {:ok, message}
109 test "Notes with only mentions are denied" do
111 "actor" => "http://localhost:4001/users/testuser",
112 "cc" => ["http://localhost:4001/users/testuser/followers"],
114 "actor" => "http://localhost:4001/users/testuser",
116 "cc" => ["http://localhost:4001/users/testuser/followers"],
117 "source" => "@user2",
119 "https://www.w3.org/ns/activitystreams#Public",
120 "http://localhost:4001/users/user2"
125 "https://www.w3.org/ns/activitystreams#Public",
126 "http://localhost:4001/users/user2"
131 assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}
134 test "Notes with no content are denied" do
136 "actor" => "http://localhost:4001/users/testuser",
137 "cc" => ["http://localhost:4001/users/testuser/followers"],
139 "actor" => "http://localhost:4001/users/testuser",
141 "cc" => ["http://localhost:4001/users/testuser/followers"],
144 "https://www.w3.org/ns/activitystreams#Public"
149 "https://www.w3.org/ns/activitystreams#Public"
154 assert NoEmptyPolicy.filter(message) == {:reject, "[NoEmptyPolicy]"}