logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

deprecation_warnings_test.exs (4515B)


  1. defmodule Pleroma.Config.DeprecationWarningsTest do
  2. use ExUnit.Case
  3. use Pleroma.Tests.Helpers
  4. import ExUnit.CaptureLog
  5. alias Pleroma.Config
  6. alias Pleroma.Config.DeprecationWarnings
  7. test "check_old_mrf_config/0" do
  8. clear_config([:instance, :rewrite_policy], Pleroma.Web.ActivityPub.MRF.NoOpPolicy)
  9. clear_config([:instance, :mrf_transparency], true)
  10. clear_config([:instance, :mrf_transparency_exclusions], [])
  11. assert capture_log(fn -> DeprecationWarnings.check_old_mrf_config() end) =~
  12. """
  13. !!!DEPRECATION WARNING!!!
  14. 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:
  15. * `config :pleroma, :instance, rewrite_policy` is now `config :pleroma, :mrf, policies`
  16. * `config :pleroma, :instance, mrf_transparency` is now `config :pleroma, :mrf, transparency`
  17. * `config :pleroma, :instance, mrf_transparency_exclusions` is now `config :pleroma, :mrf, transparency_exclusions`
  18. """
  19. end
  20. test "move_namespace_and_warn/2" do
  21. old_group1 = [:group, :key]
  22. old_group2 = [:group, :key2]
  23. old_group3 = [:group, :key3]
  24. new_group1 = [:another_group, :key4]
  25. new_group2 = [:another_group, :key5]
  26. new_group3 = [:another_group, :key6]
  27. clear_config(old_group1, 1)
  28. clear_config(old_group2, 2)
  29. clear_config(old_group3, 3)
  30. clear_config(new_group1)
  31. clear_config(new_group2)
  32. clear_config(new_group3)
  33. config_map = [
  34. {old_group1, new_group1, "\n error :key"},
  35. {old_group2, new_group2, "\n error :key2"},
  36. {old_group3, new_group3, "\n error :key3"}
  37. ]
  38. assert capture_log(fn ->
  39. DeprecationWarnings.move_namespace_and_warn(
  40. config_map,
  41. "Warning preface"
  42. )
  43. end) =~ "Warning preface\n error :key\n error :key2\n error :key3"
  44. assert Config.get(new_group1) == 1
  45. assert Config.get(new_group2) == 2
  46. assert Config.get(new_group3) == 3
  47. end
  48. test "check_media_proxy_whitelist_config/0" do
  49. clear_config([:media_proxy, :whitelist], ["https://example.com", "example2.com"])
  50. assert capture_log(fn ->
  51. DeprecationWarnings.check_media_proxy_whitelist_config()
  52. end) =~ "Your config is using old format (only domain) for MediaProxy whitelist option"
  53. end
  54. test "check_welcome_message_config/0" do
  55. clear_config([:instance, :welcome_user_nickname], "LainChan")
  56. assert capture_log(fn ->
  57. DeprecationWarnings.check_welcome_message_config()
  58. end) =~ "Your config is using the old namespace for Welcome messages configuration."
  59. end
  60. test "check_hellthread_threshold/0" do
  61. clear_config([:mrf_hellthread, :threshold], 16)
  62. assert capture_log(fn ->
  63. DeprecationWarnings.check_hellthread_threshold()
  64. end) =~ "You are using the old configuration mechanism for the hellthread filter."
  65. end
  66. test "check_activity_expiration_config/0" do
  67. clear_config([Pleroma.ActivityExpiration, :enabled], true)
  68. assert capture_log(fn ->
  69. DeprecationWarnings.check_activity_expiration_config()
  70. end) =~ "Your config is using old namespace for activity expiration configuration."
  71. end
  72. describe "check_gun_pool_options/0" do
  73. test "await_up_timeout" do
  74. config = Config.get(:connections_pool)
  75. clear_config(:connections_pool, Keyword.put(config, :await_up_timeout, 5_000))
  76. assert capture_log(fn ->
  77. DeprecationWarnings.check_gun_pool_options()
  78. end) =~
  79. "Your config is using old setting `config :pleroma, :connections_pool, await_up_timeout`."
  80. end
  81. test "pool timeout" do
  82. old_config = [
  83. federation: [
  84. size: 50,
  85. max_waiting: 10,
  86. timeout: 10_000
  87. ],
  88. media: [
  89. size: 50,
  90. max_waiting: 10,
  91. timeout: 10_000
  92. ],
  93. upload: [
  94. size: 25,
  95. max_waiting: 5,
  96. timeout: 15_000
  97. ],
  98. default: [
  99. size: 10,
  100. max_waiting: 2,
  101. timeout: 5_000
  102. ]
  103. ]
  104. clear_config(:pools, old_config)
  105. assert capture_log(fn ->
  106. DeprecationWarnings.check_gun_pool_options()
  107. end) =~
  108. "Your config is using old setting name `timeout` instead of `recv_timeout` in pool settings"
  109. end
  110. end
  111. end