{:media_removal, [{"some.removal", ""}, {"some.other.instance", "Some reason"}]}
]
- capture_log(fn -> DeprecationWarnings.check_simple_policy_tuples() end)
+ capture_log(fn -> DeprecationWarnings.warn() end)
assert Config.get([:mrf_simple]) == expected_config
end
end
end
+ describe "quarantined_instances tuples" do
+ test "gives warning when there are still strings" do
+ clear_config([:instance, :quarantined_instances], [
+ {"domain.com", "some reason"},
+ "somedomain.tld"
+ ])
+
+ assert capture_log(fn -> DeprecationWarnings.check_quarantined_instances_tuples() end) =~
+ """
+ !!!DEPRECATION WARNING!!!
+ Your config is using strings in the quarantined_instances configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
+
+ ```
+ config :pleroma, :instance,
+ quarantined_instances: ["instance.tld"]
+ ```
+
+ Is now
+
+
+ ```
+ config :pleroma, :instance,
+ quarantined_instances: [{"instance.tld", "Reason for quarantine"}]
+ ```
+ """
+ end
+
+ test "transforms config to tuples" do
+ clear_config([:instance, :quarantined_instances], [
+ {"domain.com", "some reason"},
+ "some.tld"
+ ])
+
+ expected_config = [{"domain.com", "some reason"}, {"some.tld", ""}]
+
+ capture_log(fn -> DeprecationWarnings.warn() end)
+
+ assert Config.get([:instance, :quarantined_instances]) == expected_config
+ end
+
+ test "doesn't give a warning with correct config" do
+ clear_config([:instance, :quarantined_instances], [
+ {"domain.com", "some reason"},
+ {"some.tld", ""}
+ ])
+
+ assert capture_log(fn -> DeprecationWarnings.check_quarantined_instances_tuples() end) == ""
+ end
+ end
+
+ describe "transparency_exclusions tuples" do
+ test "gives warning when there are still strings" do
+ clear_config([:mrf, :transparency_exclusions], [
+ {"domain.com", "some reason"},
+ "somedomain.tld"
+ ])
+
+ assert capture_log(fn -> DeprecationWarnings.check_transparency_exclusions_tuples() end) =~
+ """
+ !!!DEPRECATION WARNING!!!
+ Your config is using strings in the transparency_exclusions configuration instead of tuples. They should work for now, but you are advised to change to the new configuration to prevent possible issues later:
+
+ ```
+ config :pleroma, :mrf,
+ transparency_exclusions: ["instance.tld"]
+ ```
+
+ Is now
+
+
+ ```
+ config :pleroma, :mrf,
+ transparency_exclusions: [{"instance.tld", "Reason to exlude transparency"}]
+ ```
+ """
+ end
+
+ test "transforms config to tuples" do
+ clear_config([:mrf, :transparency_exclusions], [
+ {"domain.com", "some reason"},
+ "some.tld"
+ ])
+
+ expected_config = [{"domain.com", "some reason"}, {"some.tld", ""}]
+
+ capture_log(fn -> DeprecationWarnings.warn() end)
+
+ assert Config.get([:mrf, :transparency_exclusions]) == expected_config
+ end
+
+ test "doesn't give a warning with correct config" do
+ clear_config([:mrf, :transparency_exclusions], [
+ {"domain.com", "some reason"},
+ {"some.tld", ""}
+ ])
+
+ assert capture_log(fn -> DeprecationWarnings.check_transparency_exclusions_tuples() end) ==
+ ""
+ end
+ end
+
test "check_old_mrf_config/0" do
clear_config([:instance, :rewrite_policy], [])
clear_config([:instance, :mrf_transparency], true)
end) =~
"Your config is using the old setting for controlling the URL of media uploaded to your S3 bucket."
end
-
- describe "check_gun_pool_options/0" do
- test "await_up_timeout" do
- config = Config.get(:connections_pool)
- clear_config(:connections_pool, Keyword.put(config, :await_up_timeout, 5_000))
-
- assert capture_log(fn ->
- DeprecationWarnings.check_gun_pool_options()
- end) =~
- "Your config is using old setting `config :pleroma, :connections_pool, await_up_timeout`."
- end
-
- test "pool timeout" do
- old_config = [
- federation: [
- size: 50,
- max_waiting: 10,
- timeout: 10_000
- ],
- media: [
- size: 50,
- max_waiting: 10,
- timeout: 10_000
- ],
- upload: [
- size: 25,
- max_waiting: 5,
- timeout: 15_000
- ],
- default: [
- size: 10,
- max_waiting: 2,
- timeout: 5_000
- ]
- ]
-
- clear_config(:pools, old_config)
-
- assert capture_log(fn ->
- DeprecationWarnings.check_gun_pool_options()
- end) =~
- "Your config is using old setting name `timeout` instead of `recv_timeout` in pool settings"
- end
- end
-
- test "check_old_chat_shoutbox/0" do
- clear_config([:instance, :chat_limit], 1_000)
- clear_config([:chat, :enabled], true)
-
- assert capture_log(fn ->
- DeprecationWarnings.check_old_chat_shoutbox()
- end) =~
- "Your config is using the old namespace for the Shoutbox configuration."
- end
end