end
test "has a matching host" do
- clear_config([:mrf_simple, :media_removal], ["remote.instance"])
+ clear_config([:mrf_simple, :media_removal], [{"remote.instance", "Some reason"}])
media_message = build_media_message()
local_message = build_local_message()
end
test "match with wildcard domain" do
- clear_config([:mrf_simple, :media_removal], ["*.remote.instance"])
+ clear_config([:mrf_simple, :media_removal], [{"*.remote.instance", "Whatever reason"}])
media_message = build_media_message()
local_message = build_local_message()
end
test "has a matching host" do
- clear_config([:mrf_simple, :media_nsfw], ["remote.instance"])
+ clear_config([:mrf_simple, :media_nsfw], [{"remote.instance", "Whetever"}])
media_message = build_media_message()
local_message = build_local_message()
assert SimplePolicy.filter(media_message) ==
- {:ok,
- media_message
- |> put_in(["object", "tag"], ["foo", "nsfw"])
- |> put_in(["object", "sensitive"], true)}
+ {:ok, put_in(media_message, ["object", "sensitive"], true)}
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
test "match with wildcard domain" do
- clear_config([:mrf_simple, :media_nsfw], ["*.remote.instance"])
+ clear_config([:mrf_simple, :media_nsfw], [{"*.remote.instance", "yeah yeah"}])
media_message = build_media_message()
local_message = build_local_message()
assert SimplePolicy.filter(media_message) ==
- {:ok,
- media_message
- |> put_in(["object", "tag"], ["foo", "nsfw"])
- |> put_in(["object", "sensitive"], true)}
+ {:ok, put_in(media_message, ["object", "sensitive"], true)}
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
end
test "has a matching host" do
- clear_config([:mrf_simple, :report_removal], ["remote.instance"])
+ clear_config([:mrf_simple, :report_removal], [{"remote.instance", "muh"}])
report_message = build_report_message()
local_message = build_local_message()
end
test "match with wildcard domain" do
- clear_config([:mrf_simple, :report_removal], ["*.remote.instance"])
+ clear_config([:mrf_simple, :report_removal], [{"*.remote.instance", "suya"}])
report_message = build_report_message()
local_message = build_local_message()
|> URI.parse()
|> Map.fetch!(:host)
- clear_config([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
+ clear_config([:mrf_simple, :federated_timeline_removal], [{ftl_message_actor_host, "uwu"}])
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
|> URI.parse()
|> Map.fetch!(:host)
- clear_config([:mrf_simple, :federated_timeline_removal], ["*." <> ftl_message_actor_host])
+ clear_config([:mrf_simple, :federated_timeline_removal], [
+ {"*." <> ftl_message_actor_host, "owo"}
+ ])
+
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
ftl_message = Map.put(ftl_message, "cc", [])
- clear_config([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
+ clear_config([:mrf_simple, :federated_timeline_removal], [
+ {ftl_message_actor_host, "spiderwaifu goes 88w88"}
+ ])
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
refute "https://www.w3.org/ns/activitystreams#Public" in ftl_message["to"]
end
test "activity has a matching host" do
- clear_config([:mrf_simple, :reject], ["remote.instance"])
+ clear_config([:mrf_simple, :reject], [{"remote.instance", ""}])
remote_message = build_remote_message()
end
test "activity matches with wildcard domain" do
- clear_config([:mrf_simple, :reject], ["*.remote.instance"])
+ clear_config([:mrf_simple, :reject], [{"*.remote.instance", ""}])
remote_message = build_remote_message()
end
test "actor has a matching host" do
- clear_config([:mrf_simple, :reject], ["remote.instance"])
+ clear_config([:mrf_simple, :reject], [{"remote.instance", ""}])
remote_user = build_remote_user()
end
test "reject Announce when object would be rejected" do
- clear_config([:mrf_simple, :reject], ["blocked.tld"])
+ clear_config([:mrf_simple, :reject], [{"blocked.tld", ""}])
announce = %{
"type" => "Announce",
assert {:reject, _} = SimplePolicy.filter(announce)
end
+
+ test "reject by URI object" do
+ clear_config([:mrf_simple, :reject], [{"blocked.tld", ""}])
+
+ announce = %{
+ "type" => "Announce",
+ "actor" => "https://okay.tld/users/alice",
+ "object" => "https://blocked.tld/activities/1"
+ }
+
+ assert {:reject, _} = SimplePolicy.filter(announce)
+ end
end
describe "when :followers_only" do
|> URI.parse()
|> Map.fetch!(:host)
- clear_config([:mrf_simple, :followers_only], [actor_domain])
+ clear_config([:mrf_simple, :followers_only], [{actor_domain, ""}])
assert {:ok, new_activity} = SimplePolicy.filter(activity)
assert actor.follower_address in new_activity["cc"]
end
test "is not empty but activity doesn't have a matching host" do
- clear_config([:mrf_simple, :accept], ["non.matching.remote"])
+ clear_config([:mrf_simple, :accept], [{"non.matching.remote", ""}])
local_message = build_local_message()
remote_message = build_remote_message()
end
test "activity has a matching host" do
- clear_config([:mrf_simple, :accept], ["remote.instance"])
+ clear_config([:mrf_simple, :accept], [{"remote.instance", ""}])
local_message = build_local_message()
remote_message = build_remote_message()
end
test "activity matches with wildcard domain" do
- clear_config([:mrf_simple, :accept], ["*.remote.instance"])
+ clear_config([:mrf_simple, :accept], [{"*.remote.instance", ""}])
local_message = build_local_message()
remote_message = build_remote_message()
end
test "actor has a matching host" do
- clear_config([:mrf_simple, :accept], ["remote.instance"])
+ clear_config([:mrf_simple, :accept], [{"remote.instance", ""}])
remote_user = build_remote_user()
end
test "is not empty but it doesn't have a matching host" do
- clear_config([:mrf_simple, :avatar_removal], ["non.matching.remote"])
+ clear_config([:mrf_simple, :avatar_removal], [{"non.matching.remote", ""}])
remote_user = build_remote_user()
end
test "has a matching host" do
- clear_config([:mrf_simple, :avatar_removal], ["remote.instance"])
+ clear_config([:mrf_simple, :avatar_removal], [{"remote.instance", ""}])
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
end
test "match with wildcard domain" do
- clear_config([:mrf_simple, :avatar_removal], ["*.remote.instance"])
+ clear_config([:mrf_simple, :avatar_removal], [{"*.remote.instance", ""}])
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
end
test "is not empty but it doesn't have a matching host" do
- clear_config([:mrf_simple, :banner_removal], ["non.matching.remote"])
+ clear_config([:mrf_simple, :banner_removal], [{"non.matching.remote", ""}])
remote_user = build_remote_user()
end
test "has a matching host" do
- clear_config([:mrf_simple, :banner_removal], ["remote.instance"])
+ clear_config([:mrf_simple, :banner_removal], [{"remote.instance", ""}])
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
end
test "match with wildcard domain" do
- clear_config([:mrf_simple, :banner_removal], ["*.remote.instance"])
+ clear_config([:mrf_simple, :banner_removal], [{"*.remote.instance", ""}])
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
setup do: clear_config([:mrf_simple, :reject_deletes], [])
test "it accepts deletions even from rejected servers" do
- clear_config([:mrf_simple, :reject], ["remote.instance"])
+ clear_config([:mrf_simple, :reject], [{"remote.instance", ""}])
deletion_message = build_remote_deletion_message()
end
test "it accepts deletions even from non-whitelisted servers" do
- clear_config([:mrf_simple, :accept], ["non.matching.remote"])
+ clear_config([:mrf_simple, :accept], [{"non.matching.remote", ""}])
deletion_message = build_remote_deletion_message()
end
describe "when :reject_deletes is not empty but it doesn't have a matching host" do
- setup do: clear_config([:mrf_simple, :reject_deletes], ["non.matching.remote"])
+ setup do: clear_config([:mrf_simple, :reject_deletes], [{"non.matching.remote", ""}])
test "it accepts deletions even from rejected servers" do
- clear_config([:mrf_simple, :reject], ["remote.instance"])
+ clear_config([:mrf_simple, :reject], [{"remote.instance", ""}])
deletion_message = build_remote_deletion_message()
end
test "it accepts deletions even from non-whitelisted servers" do
- clear_config([:mrf_simple, :accept], ["non.matching.remote"])
+ clear_config([:mrf_simple, :accept], [{"non.matching.remote", ""}])
deletion_message = build_remote_deletion_message()
end
describe "when :reject_deletes has a matching host" do
- setup do: clear_config([:mrf_simple, :reject_deletes], ["remote.instance"])
+ setup do: clear_config([:mrf_simple, :reject_deletes], [{"remote.instance", ""}])
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
end
describe "when :reject_deletes match with wildcard domain" do
- setup do: clear_config([:mrf_simple, :reject_deletes], ["*.remote.instance"])
+ setup do: clear_config([:mrf_simple, :reject_deletes], [{"*.remote.instance", ""}])
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
defp build_local_message do
%{
- "actor" => "#{Pleroma.Web.base_url()}/users/alice",
+ "actor" => "#{Pleroma.Web.Endpoint.url()}/users/alice",
"to" => [],
"cc" => []
}