dynamic_configuration renaming
and moving it from instance settings
This commit is contained in:
parent
958d0452e4
commit
7d128ca208
13 changed files with 59 additions and 53 deletions
|
|
@ -7,8 +7,8 @@ defmodule Pleroma.Config.TransferTaskTest do
|
|||
|
||||
alias Pleroma.Web.AdminAPI.Config
|
||||
|
||||
clear_config([:instance, :dynamic_configuration]) do
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
end
|
||||
|
||||
test "transfer config values from db to env" do
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
:ok
|
||||
end
|
||||
|
||||
clear_config_all([:instance, :dynamic_configuration]) do
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||
clear_config_all([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
end
|
||||
|
||||
test "settings are migrated to db" do
|
||||
|
|
@ -127,7 +127,6 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
remote_post_retention_days: 90,
|
||||
skip_thread_containment: true,
|
||||
limit_to_local_content: :unauthenticated,
|
||||
dynamic_configuration: false,
|
||||
user_bio_length: 5000,
|
||||
user_name_length: 100,
|
||||
max_account_fields: 10,
|
||||
|
|
@ -157,7 +156,7 @@ defmodule Mix.Tasks.Pleroma.ConfigTest do
|
|||
{:ok, file} = File.read(temp_file)
|
||||
|
||||
assert file ==
|
||||
"use Mix.Config\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 no_attachment_links: true,\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 dynamic_configuration: false,\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"
|
||||
"use Mix.Config\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 no_attachment_links: true,\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
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.InstanceTest do
|
|||
assert generated_config =~ "database: \"dbname\""
|
||||
assert generated_config =~ "username: \"dbuser\""
|
||||
assert generated_config =~ "password: \"dbpass\""
|
||||
assert generated_config =~ "dynamic_configuration: true"
|
||||
assert generated_config =~ "configurable_from_database: true"
|
||||
assert generated_config =~ "http: [ip: {127, 0, 0, 1}, port: 4000]"
|
||||
assert File.read!(tmp_path() <> "setup.psql") == generated_setup_psql()
|
||||
end
|
||||
|
|
|
|||
|
|
@ -584,7 +584,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
assert json_response(conn, :no_content)
|
||||
|
||||
token_record = List.last(Pleroma.Repo.all(Pleroma.UserInviteToken))
|
||||
token_record = List.last(Repo.all(Pleroma.UserInviteToken))
|
||||
assert token_record
|
||||
refute token_record.used
|
||||
|
||||
|
|
@ -1929,8 +1929,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
describe "GET /api/pleroma/admin/config" do
|
||||
clear_config([:instance, :dynamic_configuration]) do
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
end
|
||||
|
||||
setup %{conn: conn} do
|
||||
|
|
@ -1940,9 +1940,9 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
end
|
||||
|
||||
test "when dynamic configuration is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get([:instance, :dynamic_configuration])
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], false)
|
||||
on_exit(fn -> Pleroma.Config.put([:instance, :dynamic_configuration], initial) end)
|
||||
initial = Pleroma.Config.get([:configurable_from_database])
|
||||
Pleroma.Config.put([:configurable_from_database], false)
|
||||
on_exit(fn -> Pleroma.Config.put([:configurable_from_database], initial) end)
|
||||
conn = get(conn, "/api/pleroma/admin/config")
|
||||
|
||||
assert json_response(conn, 400) ==
|
||||
|
|
@ -2016,8 +2016,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
%{conn: assign(conn, :user, admin)}
|
||||
end
|
||||
|
||||
clear_config([:instance, :dynamic_configuration]) do
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
end
|
||||
|
||||
@tag capture_log: true
|
||||
|
|
@ -2908,8 +2908,8 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
%{conn: assign(conn, :user, admin)}
|
||||
end
|
||||
|
||||
clear_config([:instance, :dynamic_configuration]) do
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], true)
|
||||
clear_config([:configurable_from_database]) do
|
||||
Pleroma.Config.put([:configurable_from_database], true)
|
||||
end
|
||||
|
||||
clear_config([:feed, :post_title]) do
|
||||
|
|
@ -2918,20 +2918,20 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIControllerTest do
|
|||
|
||||
test "transfer settings to DB and to file", %{conn: conn} do
|
||||
on_exit(fn -> :ok = File.rm("config/test.exported_from_db.secret.exs") end)
|
||||
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||
assert Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||
Mix.Tasks.Pleroma.Config.run(["migrate_to_db"])
|
||||
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) > 0
|
||||
assert Repo.aggregate(Pleroma.Web.AdminAPI.Config, :count, :id) > 0
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
assert json_response(conn, 200) == %{}
|
||||
assert Pleroma.Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||
assert Repo.all(Pleroma.Web.AdminAPI.Config) == []
|
||||
end
|
||||
|
||||
test "returns error if dynamic configuration is off", %{conn: conn} do
|
||||
initial = Pleroma.Config.get([:instance, :dynamic_configuration])
|
||||
on_exit(fn -> Pleroma.Config.put([:instance, :dynamic_configuration], initial) end)
|
||||
Pleroma.Config.put([:instance, :dynamic_configuration], false)
|
||||
initial = Pleroma.Config.get([:configurable_from_database])
|
||||
on_exit(fn -> Pleroma.Config.put([:configurable_from_database], initial) end)
|
||||
Pleroma.Config.put([:configurable_from_database], false)
|
||||
|
||||
conn = get(conn, "/api/pleroma/admin/config/migrate_from_db")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue