1 defmodule Pleroma.Config.DeprecationWarningsTest do
2 use ExUnit.Case, async: true
3 use Pleroma.Tests.Helpers
5 import ExUnit.CaptureLog
8 alias Pleroma.Config.DeprecationWarnings
10 test "check_old_mrf_config/0" do
11 clear_config([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.NoOpPolicy)
12 clear_config([:instance, :mrf_transparency], true)
13 clear_config([:instance, :mrf_transparency_exclusions], [])
15 assert capture_log(fn -> DeprecationWarnings.check_old_mrf_config() end) =~
17 !!!DEPRECATION WARNING!!!
18 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:
20 * `config :pleroma, :instance, rewrite_policy` is now `config :pleroma, :mrf, policies`
21 * `config :pleroma, :instance, mrf_transparency` is now `config :pleroma, :mrf, transparency`
22 * `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`
26 test "move_namespace_and_warn/2" do
27 old_group1 = [:group, :key]
28 old_group2 = [:group, :key2]
29 old_group3 = [:group, :key3]
31 new_group1 = [:another_group, :key4]
32 new_group2 = [:another_group, :key5]
33 new_group3 = [:another_group, :key6]
35 clear_config(old_group1, 1)
36 clear_config(old_group2, 2)
37 clear_config(old_group3, 3)
39 clear_config(new_group1)
40 clear_config(new_group2)
41 clear_config(new_group3)
44 {old_group1, new_group1, "\n error :key"},
45 {old_group2, new_group2, "\n error :key2"},
46 {old_group3, new_group3, "\n error :key3"}
49 assert capture_log(fn ->
50 DeprecationWarnings.move_namespace_and_warn(
54 end) =~ "Warning preface\n error :key\n error :key2\n error :key3"
56 assert Config.get(new_group1) == 1
57 assert Config.get(new_group2) == 2
58 assert Config.get(new_group3) == 3
61 test "check_media_proxy_whitelist_config/0" do
62 clear_config([:media_proxy, :whitelist], ["https://example.com", "example2.com"])
64 assert capture_log(fn ->
65 DeprecationWarnings.check_media_proxy_whitelist_config()
66 end) =~ "Your config is using old format (only domain) for MediaProxy whitelist option"
69 describe "check_gun_pool_options/0" do
70 test "await_up_timeout" do
71 config = Config.get(:connections_pool)
72 clear_config(:connections_pool, Keyword.put(config, :await_up_timeout, 5_000))
74 assert capture_log(fn ->
75 DeprecationWarnings.check_gun_pool_options()
77 "Your config is using old setting name `await_up_timeout` instead of `connect_timeout`"
80 test "pool timeout" do
104 clear_config(:pools, old_config)
106 assert capture_log(fn ->
107 DeprecationWarnings.check_gun_pool_options()
109 "Your config is using old setting name `timeout` instead of `recv_timeout` in pool settings"