projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changing references of freenode to libera.chat
[akkoma]
/
test
/
pleroma
/
web
/
activity_pub
/
mrf
/
simple_policy_test.exs
diff --git
a/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs
b/test/pleroma/web/activity_pub/mrf/simple_policy_test.exs
index d7dde62c40c8643bf2fbafc3b4fc7c08f6b17ec9..5c0aff26eb3bb6f1f714613cda67f8ea4b87d337 100644
(file)
--- a/
test/pleroma/web/activity_pub/mrf/simple_policy_test.exs
+++ b/
test/pleroma/web/activity_pub/mrf/simple_policy_test.exs
@@
-1,11
+1,10
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-202
0
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-202
1
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
use Pleroma.DataCase
import Pleroma.Factory
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
use Pleroma.DataCase
import Pleroma.Factory
- alias Pleroma.Config
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
alias Pleroma.Web.CommonAPI
alias Pleroma.Web.ActivityPub.MRF.SimplePolicy
alias Pleroma.Web.CommonAPI
@@
-25,7
+24,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :media_removal" do
test "is empty" do
describe "when :media_removal" do
test "is empty" do
-
Config.put
([:mrf_simple, :media_removal], [])
+
clear_config
([:mrf_simple, :media_removal], [])
media_message = build_media_message()
local_message = build_local_message()
media_message = build_media_message()
local_message = build_local_message()
@@
-34,7
+33,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "has a matching host" do
end
test "has a matching host" do
-
Config.put
([:mrf_simple, :media_removal], ["remote.instance"])
+
clear_config
([:mrf_simple, :media_removal], ["remote.instance"])
media_message = build_media_message()
local_message = build_local_message()
media_message = build_media_message()
local_message = build_local_message()
@@
-47,7
+46,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "match with wildcard domain" do
end
test "match with wildcard domain" do
-
Config.put
([:mrf_simple, :media_removal], ["*.remote.instance"])
+
clear_config
([:mrf_simple, :media_removal], ["*.remote.instance"])
media_message = build_media_message()
local_message = build_local_message()
media_message = build_media_message()
local_message = build_local_message()
@@
-62,7
+61,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :media_nsfw" do
test "is empty" do
describe "when :media_nsfw" do
test "is empty" do
-
Config.put
([:mrf_simple, :media_nsfw], [])
+
clear_config
([:mrf_simple, :media_nsfw], [])
media_message = build_media_message()
local_message = build_local_message()
media_message = build_media_message()
local_message = build_local_message()
@@
-71,29
+70,23
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "has a matching host" do
end
test "has a matching host" do
-
Config.put
([:mrf_simple, :media_nsfw], ["remote.instance"])
+
clear_config
([:mrf_simple, :media_nsfw], ["remote.instance"])
media_message = build_media_message()
local_message = build_local_message()
assert SimplePolicy.filter(media_message) ==
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
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
test "match with wildcard domain" do
-
Config.put
([:mrf_simple, :media_nsfw], ["*.remote.instance"])
+
clear_config
([:mrf_simple, :media_nsfw], ["*.remote.instance"])
media_message = build_media_message()
local_message = build_local_message()
assert SimplePolicy.filter(media_message) ==
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
assert SimplePolicy.filter(local_message) == {:ok, local_message}
end
@@
-113,7
+106,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :report_removal" do
test "is empty" do
describe "when :report_removal" do
test "is empty" do
-
Config.put
([:mrf_simple, :report_removal], [])
+
clear_config
([:mrf_simple, :report_removal], [])
report_message = build_report_message()
local_message = build_local_message()
report_message = build_report_message()
local_message = build_local_message()
@@
-122,7
+115,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "has a matching host" do
end
test "has a matching host" do
-
Config.put
([:mrf_simple, :report_removal], ["remote.instance"])
+
clear_config
([:mrf_simple, :report_removal], ["remote.instance"])
report_message = build_report_message()
local_message = build_local_message()
report_message = build_report_message()
local_message = build_local_message()
@@
-131,7
+124,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "match with wildcard domain" do
end
test "match with wildcard domain" do
-
Config.put
([:mrf_simple, :report_removal], ["*.remote.instance"])
+
clear_config
([:mrf_simple, :report_removal], ["*.remote.instance"])
report_message = build_report_message()
local_message = build_local_message()
report_message = build_report_message()
local_message = build_local_message()
@@
-149,7
+142,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :federated_timeline_removal" do
test "is empty" do
describe "when :federated_timeline_removal" do
test "is empty" do
-
Config.put
([:mrf_simple, :federated_timeline_removal], [])
+
clear_config
([:mrf_simple, :federated_timeline_removal], [])
{_, ftl_message} = build_ftl_actor_and_message()
local_message = build_local_message()
{_, ftl_message} = build_ftl_actor_and_message()
local_message = build_local_message()
@@
-166,7
+159,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|> URI.parse()
|> Map.fetch!(:host)
|> URI.parse()
|> Map.fetch!(:host)
-
Config.put
([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
+
clear_config
([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
@@
-187,7
+180,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|> URI.parse()
|> Map.fetch!(:host)
|> URI.parse()
|> Map.fetch!(:host)
-
Config.put
([:mrf_simple, :federated_timeline_removal], ["*." <> ftl_message_actor_host])
+
clear_config
([:mrf_simple, :federated_timeline_removal], ["*." <> ftl_message_actor_host])
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
local_message = build_local_message()
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
@@
-210,7
+203,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
ftl_message = Map.put(ftl_message, "cc", [])
ftl_message = Map.put(ftl_message, "cc", [])
-
Config.put
([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
+
clear_config
([:mrf_simple, :federated_timeline_removal], [ftl_message_actor_host])
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
refute "https://www.w3.org/ns/activitystreams#Public" in ftl_message["to"]
assert {:ok, ftl_message} = SimplePolicy.filter(ftl_message)
refute "https://www.w3.org/ns/activitystreams#Public" in ftl_message["to"]
@@
-231,7
+224,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :reject" do
test "is empty" do
describe "when :reject" do
test "is empty" do
-
Config.put
([:mrf_simple, :reject], [])
+
clear_config
([:mrf_simple, :reject], [])
remote_message = build_remote_message()
remote_message = build_remote_message()
@@
-239,7
+232,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "activity has a matching host" do
end
test "activity has a matching host" do
-
Config.put
([:mrf_simple, :reject], ["remote.instance"])
+
clear_config
([:mrf_simple, :reject], ["remote.instance"])
remote_message = build_remote_message()
remote_message = build_remote_message()
@@
-247,7
+240,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "activity matches with wildcard domain" do
end
test "activity matches with wildcard domain" do
-
Config.put
([:mrf_simple, :reject], ["*.remote.instance"])
+
clear_config
([:mrf_simple, :reject], ["*.remote.instance"])
remote_message = build_remote_message()
remote_message = build_remote_message()
@@
-255,7
+248,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "actor has a matching host" do
end
test "actor has a matching host" do
-
Config.put
([:mrf_simple, :reject], ["remote.instance"])
+
clear_config
([:mrf_simple, :reject], ["remote.instance"])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-265,7
+258,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :followers_only" do
test "is empty" do
describe "when :followers_only" do
test "is empty" do
-
Config.put
([:mrf_simple, :followers_only], [])
+
clear_config
([:mrf_simple, :followers_only], [])
{_, ftl_message} = build_ftl_actor_and_message()
local_message = build_local_message()
{_, ftl_message} = build_ftl_actor_and_message()
local_message = build_local_message()
@@
-305,7
+298,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
|> URI.parse()
|> Map.fetch!(:host)
|> URI.parse()
|> Map.fetch!(:host)
-
Config.put
([: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"]
assert {:ok, new_activity} = SimplePolicy.filter(activity)
assert actor.follower_address in new_activity["cc"]
@@
-323,7
+316,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :accept" do
test "is empty" do
describe "when :accept" do
test "is empty" do
-
Config.put
([:mrf_simple, :accept], [])
+
clear_config
([:mrf_simple, :accept], [])
local_message = build_local_message()
remote_message = build_remote_message()
local_message = build_local_message()
remote_message = build_remote_message()
@@
-333,7
+326,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "is not empty but activity doesn't have a matching host" do
end
test "is not empty but activity doesn't have a matching host" do
-
Config.put
([:mrf_simple, :accept], ["non.matching.remote"])
+
clear_config
([:mrf_simple, :accept], ["non.matching.remote"])
local_message = build_local_message()
remote_message = build_remote_message()
local_message = build_local_message()
remote_message = build_remote_message()
@@
-343,7
+336,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "activity has a matching host" do
end
test "activity has a matching host" do
-
Config.put
([:mrf_simple, :accept], ["remote.instance"])
+
clear_config
([:mrf_simple, :accept], ["remote.instance"])
local_message = build_local_message()
remote_message = build_remote_message()
local_message = build_local_message()
remote_message = build_remote_message()
@@
-353,7
+346,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "activity matches with wildcard domain" do
end
test "activity matches with wildcard domain" do
-
Config.put
([:mrf_simple, :accept], ["*.remote.instance"])
+
clear_config
([:mrf_simple, :accept], ["*.remote.instance"])
local_message = build_local_message()
remote_message = build_remote_message()
local_message = build_local_message()
remote_message = build_remote_message()
@@
-363,7
+356,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "actor has a matching host" do
end
test "actor has a matching host" do
-
Config.put
([:mrf_simple, :accept], ["remote.instance"])
+
clear_config
([:mrf_simple, :accept], ["remote.instance"])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-373,7
+366,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :avatar_removal" do
test "is empty" do
describe "when :avatar_removal" do
test "is empty" do
-
Config.put
([:mrf_simple, :avatar_removal], [])
+
clear_config
([:mrf_simple, :avatar_removal], [])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-381,7
+374,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "is not empty but it doesn't have a matching host" do
end
test "is not empty but it doesn't have a matching host" do
-
Config.put
([:mrf_simple, :avatar_removal], ["non.matching.remote"])
+
clear_config
([:mrf_simple, :avatar_removal], ["non.matching.remote"])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-389,7
+382,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "has a matching host" do
end
test "has a matching host" do
-
Config.put
([: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)
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
@@
-398,7
+391,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "match with wildcard domain" do
end
test "match with wildcard domain" do
-
Config.put
([: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)
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
@@
-409,7
+402,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
describe "when :banner_removal" do
test "is empty" do
describe "when :banner_removal" do
test "is empty" do
-
Config.put
([:mrf_simple, :banner_removal], [])
+
clear_config
([:mrf_simple, :banner_removal], [])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-417,7
+410,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "is not empty but it doesn't have a matching host" do
end
test "is not empty but it doesn't have a matching host" do
-
Config.put
([:mrf_simple, :banner_removal], ["non.matching.remote"])
+
clear_config
([:mrf_simple, :banner_removal], ["non.matching.remote"])
remote_user = build_remote_user()
remote_user = build_remote_user()
@@
-425,7
+418,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "has a matching host" do
end
test "has a matching host" do
-
Config.put
([: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)
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
@@
-434,7
+427,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "match with wildcard domain" do
end
test "match with wildcard domain" do
-
Config.put
([: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)
remote_user = build_remote_user()
{:ok, filtered} = SimplePolicy.filter(remote_user)
@@
-444,10
+437,10
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
describe "when :reject_deletes is empty" do
end
describe "when :reject_deletes is empty" do
- setup do:
Config.put
([:mrf_simple, :reject_deletes], [])
+ setup do:
clear_config
([:mrf_simple, :reject_deletes], [])
test "it accepts deletions even from rejected servers" do
test "it accepts deletions even from rejected servers" do
-
Config.put
([:mrf_simple, :reject], ["remote.instance"])
+
clear_config
([:mrf_simple, :reject], ["remote.instance"])
deletion_message = build_remote_deletion_message()
deletion_message = build_remote_deletion_message()
@@
-455,7
+448,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "it accepts deletions even from non-whitelisted servers" do
end
test "it accepts deletions even from non-whitelisted servers" do
-
Config.put
([:mrf_simple, :accept], ["non.matching.remote"])
+
clear_config
([:mrf_simple, :accept], ["non.matching.remote"])
deletion_message = build_remote_deletion_message()
deletion_message = build_remote_deletion_message()
@@
-464,10
+457,10
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
describe "when :reject_deletes is not empty but it doesn't have a matching host" do
end
describe "when :reject_deletes is not empty but it doesn't have a matching host" do
- setup do:
Config.put
([: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
test "it accepts deletions even from rejected servers" do
-
Config.put
([:mrf_simple, :reject], ["remote.instance"])
+
clear_config
([:mrf_simple, :reject], ["remote.instance"])
deletion_message = build_remote_deletion_message()
deletion_message = build_remote_deletion_message()
@@
-475,7
+468,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
test "it accepts deletions even from non-whitelisted servers" do
end
test "it accepts deletions even from non-whitelisted servers" do
-
Config.put
([:mrf_simple, :accept], ["non.matching.remote"])
+
clear_config
([:mrf_simple, :accept], ["non.matching.remote"])
deletion_message = build_remote_deletion_message()
deletion_message = build_remote_deletion_message()
@@
-484,7
+477,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
describe "when :reject_deletes has a matching host" do
end
describe "when :reject_deletes has a matching host" do
- setup do:
Config.put
([: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()
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()
@@
-494,7
+487,7
@@
defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do
end
describe "when :reject_deletes match with wildcard domain" do
end
describe "when :reject_deletes match with wildcard domain" do
- setup do:
Config.put
([: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()
test "it rejects the deletion" do
deletion_message = build_remote_deletion_message()