Merge branch 'feature/1631-redesign-mrf-configuration' into 'develop'
Moving mrf settings from instance to separate mrf group Closes #1631 See merge request pleroma/pleroma!2320
This commit is contained in:
commit
c7d69e9256
19 changed files with 257 additions and 127 deletions
57
test/config/deprecation_warnings_test.exs
Normal file
57
test/config/deprecation_warnings_test.exs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
defmodule Pleroma.Config.DeprecationWarningsTest do
|
||||
use ExUnit.Case, async: true
|
||||
use Pleroma.Tests.Helpers
|
||||
|
||||
import ExUnit.CaptureLog
|
||||
|
||||
test "check_old_mrf_config/0" do
|
||||
clear_config([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.NoOpPolicy)
|
||||
clear_config([:instance, :mrf_transparency], true)
|
||||
clear_config([:instance, :mrf_transparency_exclusions], [])
|
||||
|
||||
assert capture_log(fn -> Pleroma.Config.DeprecationWarnings.check_old_mrf_config() end) =~
|
||||
"""
|
||||
!!!DEPRECATION WARNING!!!
|
||||
Your config is using old namespaces for MRF configuration. They should work for now, but you are advised to change to new namespaces to prevent possible issues later:
|
||||
|
||||
* `config :pleroma, :instance, rewrite_policy` is now `config :pleroma, :mrf, policies`
|
||||
* `config :pleroma, :instance, mrf_transparency` is now `config :pleroma, :mrf, transparency`
|
||||
* `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`
|
||||
"""
|
||||
end
|
||||
|
||||
test "move_namespace_and_warn/2" do
|
||||
old_group1 = [:group, :key]
|
||||
old_group2 = [:group, :key2]
|
||||
old_group3 = [:group, :key3]
|
||||
|
||||
new_group1 = [:another_group, :key4]
|
||||
new_group2 = [:another_group, :key5]
|
||||
new_group3 = [:another_group, :key6]
|
||||
|
||||
clear_config(old_group1, 1)
|
||||
clear_config(old_group2, 2)
|
||||
clear_config(old_group3, 3)
|
||||
|
||||
clear_config(new_group1)
|
||||
clear_config(new_group2)
|
||||
clear_config(new_group3)
|
||||
|
||||
config_map = [
|
||||
{old_group1, new_group1, "\n error :key"},
|
||||
{old_group2, new_group2, "\n error :key2"},
|
||||
{old_group3, new_group3, "\n error :key3"}
|
||||
]
|
||||
|
||||
assert capture_log(fn ->
|
||||
Pleroma.Config.DeprecationWarnings.move_namespace_and_warn(
|
||||
config_map,
|
||||
"Warning preface"
|
||||
)
|
||||
end) =~ "Warning preface\n error :key\n error :key2\n error :key3"
|
||||
|
||||
assert Pleroma.Config.get(new_group1) == 1
|
||||
assert Pleroma.Config.get(new_group2) == 2
|
||||
assert Pleroma.Config.get(new_group3) == 3
|
||||
end
|
||||
end
|
||||
|
|
@ -121,14 +121,11 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
federation_reachability_timeout_days: 7,
|
||||
federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],
|
||||
allow_relay: true,
|
||||
rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,
|
||||
public: true,
|
||||
quarantined_instances: [],
|
||||
managed_config: true,
|
||||
static_dir: "instance/static/",
|
||||
allowed_post_formats: ["text/plain", "text/html", "text/markdown", "text/bbcode"],
|
||||
mrf_transparency: true,
|
||||
mrf_transparency_exclusions: [],
|
||||
autofollowed_nicknames: [],
|
||||
max_pinned_statuses: 1,
|
||||
attachment_links: false,
|
||||
|
|
@ -175,7 +172,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
end
|
||||
|
||||
assert file ==
|
||||
"#{header}\n\nconfig :pleroma, :instance,\n name: \"Pleroma\",\n email: \"example@example.com\",\n notify_email: \"noreply@example.com\",\n description: \"A Pleroma instance, an alternative fediverse server\",\n limit: 5000,\n chat_limit: 5000,\n remote_limit: 100_000,\n upload_limit: 16_000_000,\n avatar_upload_limit: 2_000_000,\n background_upload_limit: 4_000_000,\n banner_upload_limit: 4_000_000,\n poll_limits: %{\n max_expiration: 31_536_000,\n max_option_chars: 200,\n max_options: 20,\n min_expiration: 0\n },\n registrations_open: true,\n federating: true,\n federation_incoming_replies_max_depth: 100,\n federation_reachability_timeout_days: 7,\n federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],\n allow_relay: true,\n rewrite_policy: Pleroma.Web.ActivityPub.MRF.NoOpPolicy,\n public: true,\n quarantined_instances: [],\n managed_config: true,\n static_dir: \"instance/static/\",\n allowed_post_formats: [\"text/plain\", \"text/html\", \"text/markdown\", \"text/bbcode\"],\n mrf_transparency: true,\n mrf_transparency_exclusions: [],\n autofollowed_nicknames: [],\n max_pinned_statuses: 1,\n attachment_links: false,\n welcome_user_nickname: nil,\n welcome_message: nil,\n max_report_comment_size: 1000,\n safe_dm_mentions: false,\n healthcheck: false,\n remote_post_retention_days: 90,\n skip_thread_containment: true,\n limit_to_local_content: :unauthenticated,\n user_bio_length: 5000,\n user_name_length: 100,\n max_account_fields: 10,\n max_remote_account_fields: 20,\n account_field_name_length: 512,\n account_field_value_length: 2048,\n external_user_synchronization: true,\n extended_nickname_format: true,\n multi_factor_authentication: [\n totp: [digits: 6, period: 30],\n backup_codes: [number: 2, length: 6]\n ]\n"
|
||||
"#{header}\n\nconfig :pleroma, :instance,\n name: \"Pleroma\",\n email: \"example@example.com\",\n notify_email: \"noreply@example.com\",\n description: \"A Pleroma instance, an alternative fediverse server\",\n limit: 5000,\n chat_limit: 5000,\n remote_limit: 100_000,\n upload_limit: 16_000_000,\n avatar_upload_limit: 2_000_000,\n background_upload_limit: 4_000_000,\n banner_upload_limit: 4_000_000,\n poll_limits: %{\n max_expiration: 31_536_000,\n max_option_chars: 200,\n max_options: 20,\n min_expiration: 0\n },\n registrations_open: true,\n federating: true,\n federation_incoming_replies_max_depth: 100,\n federation_reachability_timeout_days: 7,\n federation_publisher_modules: [Pleroma.Web.ActivityPub.Publisher],\n allow_relay: true,\n public: true,\n quarantined_instances: [],\n managed_config: true,\n static_dir: \"instance/static/\",\n allowed_post_formats: [\"text/plain\", \"text/html\", \"text/markdown\", \"text/bbcode\"],\n autofollowed_nicknames: [],\n max_pinned_statuses: 1,\n attachment_links: false,\n welcome_user_nickname: nil,\n welcome_message: nil,\n max_report_comment_size: 1000,\n safe_dm_mentions: false,\n healthcheck: false,\n remote_post_retention_days: 90,\n skip_thread_containment: true,\n limit_to_local_content: :unauthenticated,\n user_bio_length: 5000,\n user_name_length: 100,\n max_account_fields: 10,\n max_remote_account_fields: 20,\n account_field_name_length: 512,\n account_field_value_length: 2048,\n external_user_synchronization: true,\n extended_nickname_format: true,\n multi_factor_authentication: [\n totp: [digits: 6, period: 30],\n backup_codes: [number: 2, length: 6]\n ]\n"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2055,11 +2055,11 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
|
|||
end
|
||||
|
||||
describe "global activity expiration" do
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
setup do: clear_config([:mrf, :policies])
|
||||
|
||||
test "creates an activity expiration for local Create activities" do
|
||||
Pleroma.Config.put(
|
||||
[:instance, :rewrite_policy],
|
||||
[:mrf, :policies],
|
||||
Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -60,8 +60,6 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
|||
end
|
||||
|
||||
describe "describe/0" do
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
|
||||
test "it works as expected with noop policy" do
|
||||
expected = %{
|
||||
mrf_policies: ["NoOpPolicy"],
|
||||
|
|
@ -72,7 +70,7 @@ defmodule Pleroma.Web.ActivityPub.MRFTest do
|
|||
end
|
||||
|
||||
test "it works as expected with mock policy" do
|
||||
Pleroma.Config.put([:instance, :rewrite_policy], [MRFModuleMock])
|
||||
clear_config([:mrf, :policies], [MRFModuleMock])
|
||||
|
||||
expected = %{
|
||||
mrf_policies: ["MRFModuleMock"],
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
|
||||
setup_all do: clear_config([:instance, :federating], true)
|
||||
setup do: clear_config([:instance, :allow_relay])
|
||||
setup do: clear_config([:instance, :rewrite_policy])
|
||||
setup do: clear_config([:mrf, :policies])
|
||||
setup do: clear_config([:mrf_keyword])
|
||||
|
||||
describe "Publish an activity" do
|
||||
|
|
@ -158,7 +158,7 @@ defmodule Pleroma.Web.FederatorTest do
|
|||
Pleroma.Config.put([:mrf_keyword, :reject], ["lain"])
|
||||
|
||||
Pleroma.Config.put(
|
||||
[:instance, :rewrite_policy],
|
||||
[:mrf, :policies],
|
||||
Pleroma.Web.ActivityPub.MRF.KeywordPolicy
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
end
|
||||
|
||||
test "returns fieldsLimits field", %{conn: conn} do
|
||||
Config.put([:instance, :max_account_fields], 10)
|
||||
Config.put([:instance, :max_remote_account_fields], 15)
|
||||
Config.put([:instance, :account_field_name_length], 255)
|
||||
Config.put([:instance, :account_field_value_length], 2048)
|
||||
clear_config([:instance, :max_account_fields], 10)
|
||||
clear_config([:instance, :max_remote_account_fields], 15)
|
||||
clear_config([:instance, :account_field_name_length], 255)
|
||||
clear_config([:instance, :account_field_value_length], 2048)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -84,8 +84,7 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
end
|
||||
|
||||
test "it returns the safe_dm_mentions feature if enabled", %{conn: conn} do
|
||||
option = Config.get([:instance, :safe_dm_mentions])
|
||||
Config.put([:instance, :safe_dm_mentions], true)
|
||||
clear_config([:instance, :safe_dm_mentions], true)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -102,8 +101,6 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
|> json_response(:ok)
|
||||
|
||||
refute "safe_dm_mentions" in response["metadata"]["features"]
|
||||
|
||||
Config.put([:instance, :safe_dm_mentions], option)
|
||||
end
|
||||
|
||||
describe "`metadata/federation/enabled`" do
|
||||
|
|
@ -156,14 +153,11 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
end
|
||||
|
||||
test "it shows MRF transparency data if enabled", %{conn: conn} do
|
||||
config = Config.get([:instance, :rewrite_policy])
|
||||
Config.put([:instance, :rewrite_policy], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
|
||||
option = Config.get([:instance, :mrf_transparency])
|
||||
Config.put([:instance, :mrf_transparency], true)
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
clear_config([:mrf, :transparency], true)
|
||||
|
||||
simple_config = %{"reject" => ["example.com"]}
|
||||
Config.put(:mrf_simple, simple_config)
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -171,26 +165,17 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
|> json_response(:ok)
|
||||
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == simple_config
|
||||
|
||||
Config.put([:instance, :rewrite_policy], config)
|
||||
Config.put([:instance, :mrf_transparency], option)
|
||||
Config.put(:mrf_simple, %{})
|
||||
end
|
||||
|
||||
test "it performs exclusions from MRF transparency data if configured", %{conn: conn} do
|
||||
config = Config.get([:instance, :rewrite_policy])
|
||||
Config.put([:instance, :rewrite_policy], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
|
||||
option = Config.get([:instance, :mrf_transparency])
|
||||
Config.put([:instance, :mrf_transparency], true)
|
||||
|
||||
exclusions = Config.get([:instance, :mrf_transparency_exclusions])
|
||||
Config.put([:instance, :mrf_transparency_exclusions], ["other.site"])
|
||||
clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.SimplePolicy])
|
||||
clear_config([:mrf, :transparency], true)
|
||||
clear_config([:mrf, :transparency_exclusions], ["other.site"])
|
||||
|
||||
simple_config = %{"reject" => ["example.com", "other.site"]}
|
||||
expected_config = %{"reject" => ["example.com"]}
|
||||
clear_config(:mrf_simple, simple_config)
|
||||
|
||||
Config.put(:mrf_simple, simple_config)
|
||||
expected_config = %{"reject" => ["example.com"]}
|
||||
|
||||
response =
|
||||
conn
|
||||
|
|
@ -199,10 +184,5 @@ defmodule Pleroma.Web.NodeInfoTest do
|
|||
|
||||
assert response["metadata"]["federation"]["mrf_simple"] == expected_config
|
||||
assert response["metadata"]["federation"]["exclusions"] == true
|
||||
|
||||
Config.put([:instance, :rewrite_policy], config)
|
||||
Config.put([:instance, :mrf_transparency], option)
|
||||
Config.put([:instance, :mrf_transparency_exclusions], exclusions)
|
||||
Config.put(:mrf_simple, %{})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
|
|||
|
||||
setup do
|
||||
clear_config([ActivityExpiration, :enabled])
|
||||
clear_config([:instance, :rewrite_policy])
|
||||
end
|
||||
|
||||
test "deletes an expiration activity" do
|
||||
|
|
@ -42,10 +41,7 @@ defmodule Pleroma.Workers.Cron.PurgeExpiredActivitiesWorkerTest do
|
|||
test "works with ActivityExpirationPolicy" do
|
||||
Pleroma.Config.put([ActivityExpiration, :enabled], true)
|
||||
|
||||
Pleroma.Config.put(
|
||||
[:instance, :rewrite_policy],
|
||||
Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy
|
||||
)
|
||||
clear_config([:mrf, :policies], Pleroma.Web.ActivityPub.MRF.ActivityExpirationPolicy)
|
||||
|
||||
user = insert(:user)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue