1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
6 use Pleroma.Web.ConnCase, async: true
8 import ExUnit.CaptureLog
12 alias Pleroma.ConfigDB
15 admin = insert(:user, is_admin: true)
16 token = insert(:oauth_admin_token, user: admin)
20 |> assign(:user, admin)
21 |> assign(:token, token)
23 {:ok, %{admin: admin, token: token, conn: conn}}
26 describe "GET /api/pleroma/admin/config" do
27 setup do: clear_config(:configurable_from_database, true)
29 test "when configuration from database is off", %{conn: conn} do
30 Config.put(:configurable_from_database, false)
31 conn = get(conn, "/api/pleroma/admin/config")
33 assert json_response_and_validate_schema(conn, 400) ==
35 "error" => "To use this endpoint you need to enable configuration from database."
39 test "with settings only in db", %{conn: conn} do
40 config1 = insert(:config)
41 config2 = insert(:config)
43 conn = get(conn, "/api/pleroma/admin/config?only_db=true")
48 "group" => ":pleroma",
53 "group" => ":pleroma",
58 } = json_response_and_validate_schema(conn, 200)
60 assert key1 == config1.key
61 assert key2 == config2.key
64 test "db is added to settings that are in db", %{conn: conn} do
65 _config = insert(:config, key: ":instance", value: ConfigDB.to_binary(name: "Some name"))
67 %{"configs" => configs} =
69 |> get("/api/pleroma/admin/config")
70 |> json_response_and_validate_schema(200)
73 Enum.filter(configs, fn %{"group" => group, "key" => key} ->
74 group == ":pleroma" and key == ":instance"
77 assert instance_config["db"] == [":name"]
80 test "merged default setting with db settings", %{conn: conn} do
81 config1 = insert(:config)
82 config2 = insert(:config)
86 value: ConfigDB.to_binary(k1: :v1, k2: :v2)
89 %{"configs" => configs} =
91 |> get("/api/pleroma/admin/config")
92 |> json_response_and_validate_schema(200)
94 assert length(configs) > 3
97 Enum.filter(configs, fn %{"group" => group, "key" => key} ->
98 group == ":pleroma" and key in [config1.key, config2.key, config3.key]
101 assert length(received_configs) == 3
105 |> ConfigDB.from_binary()
107 |> ConfigDB.convert()
109 Enum.each(received_configs, fn %{"value" => value, "db" => db} ->
110 assert db in [[config1.key], [config2.key], db_keys]
113 ConfigDB.from_binary_with_convert(config1.value),
114 ConfigDB.from_binary_with_convert(config2.value),
115 ConfigDB.from_binary_with_convert(config3.value)
120 test "subkeys with full update right merge", %{conn: conn} do
124 value: ConfigDB.to_binary(groups: [a: 1, b: 2], key: [a: 1])
130 value: ConfigDB.to_binary(mascots: [a: 1, b: 2], key: [a: 1])
133 %{"configs" => configs} =
135 |> get("/api/pleroma/admin/config")
136 |> json_response_and_validate_schema(200)
139 Enum.filter(configs, fn %{"group" => group, "key" => key} ->
140 group == ":pleroma" and key in [config1.key, config2.key]
143 emoji = Enum.find(vals, fn %{"key" => key} -> key == ":emoji" end)
144 assets = Enum.find(vals, fn %{"key" => key} -> key == ":assets" end)
146 emoji_val = ConfigDB.transform_with_out_binary(emoji["value"])
147 assets_val = ConfigDB.transform_with_out_binary(assets["value"])
149 assert emoji_val[:groups] == [a: 1, b: 2]
150 assert assets_val[:mascots] == [a: 1, b: 2]
154 test "POST /api/pleroma/admin/config error", %{conn: conn} do
157 |> put_req_header("content-type", "application/json")
158 |> post("/api/pleroma/admin/config", %{"configs" => []})
160 assert json_response_and_validate_schema(conn, 400) ==
161 %{"error" => "To use this endpoint you need to enable configuration from database."}
164 describe "POST /api/pleroma/admin/config" do
166 http = Application.get_env(:pleroma, :http)
169 Application.delete_env(:pleroma, :key1)
170 Application.delete_env(:pleroma, :key2)
171 Application.delete_env(:pleroma, :key3)
172 Application.delete_env(:pleroma, :key4)
173 Application.delete_env(:pleroma, :keyaa1)
174 Application.delete_env(:pleroma, :keyaa2)
175 Application.delete_env(:pleroma, Pleroma.Web.Endpoint.NotReal)
176 Application.delete_env(:pleroma, Pleroma.Captcha.NotReal)
177 Application.put_env(:pleroma, :http, http)
178 Application.put_env(:tesla, :adapter, Tesla.Mock)
179 Restarter.Pleroma.refresh()
183 setup do: clear_config(:configurable_from_database, true)
185 @tag capture_log: true
186 test "create new config setting in db", %{conn: conn} do
187 ueberauth = Application.get_env(:ueberauth, Ueberauth)
188 on_exit(fn -> Application.put_env(:ueberauth, Ueberauth, ueberauth) end)
192 |> put_req_header("content-type", "application/json")
193 |> post("/api/pleroma/admin/config", %{
195 %{group: ":pleroma", key: ":key1", value: "value1"},
199 value: [%{"tuple" => [":consumer_secret", "aaaa"]}]
205 ":nested_1" => "nested_value1",
207 %{":nested_22" => "nested_value222"},
208 %{":nested_33" => %{":nested_44" => "nested_444"}}
216 %{"nested_3" => ":nested_3", "nested_33" => "nested_33"},
217 %{"nested_4" => true}
223 value: %{":nested_5" => ":upload", "endpoint" => "https://example.com"}
228 value: %{"tuple" => ["string", "Pleroma.Captcha.NotReal", []]}
233 assert json_response_and_validate_schema(conn, 200) == %{
236 "group" => ":pleroma",
242 "group" => ":ueberauth",
243 "key" => "Ueberauth",
244 "value" => [%{"tuple" => [":consumer_secret", "aaaa"]}],
245 "db" => [":consumer_secret"]
248 "group" => ":pleroma",
251 ":nested_1" => "nested_value1",
253 %{":nested_22" => "nested_value222"},
254 %{":nested_33" => %{":nested_44" => "nested_444"}}
260 "group" => ":pleroma",
263 %{"nested_3" => ":nested_3", "nested_33" => "nested_33"},
264 %{"nested_4" => true}
269 "group" => ":pleroma",
271 "value" => %{"endpoint" => "https://example.com", ":nested_5" => ":upload"},
277 "value" => %{"tuple" => ["string", "Pleroma.Captcha.NotReal", []]},
283 assert Application.get_env(:pleroma, :key1) == "value1"
285 assert Application.get_env(:pleroma, :key2) == %{
286 nested_1: "nested_value1",
288 %{nested_22: "nested_value222"},
289 %{nested_33: %{nested_44: "nested_444"}}
293 assert Application.get_env(:pleroma, :key3) == [
294 %{"nested_3" => :nested_3, "nested_33" => "nested_33"},
295 %{"nested_4" => true}
298 assert Application.get_env(:pleroma, :key4) == %{
299 "endpoint" => "https://example.com",
303 assert Application.get_env(:idna, :key5) == {"string", Pleroma.Captcha.NotReal, []}
306 test "save configs setting without explicit key", %{conn: conn} do
307 level = Application.get_env(:quack, :level)
308 meta = Application.get_env(:quack, :meta)
309 webhook_url = Application.get_env(:quack, :webhook_url)
312 Application.put_env(:quack, :level, level)
313 Application.put_env(:quack, :meta, meta)
314 Application.put_env(:quack, :webhook_url, webhook_url)
319 |> put_req_header("content-type", "application/json")
320 |> post("/api/pleroma/admin/config", %{
335 value: "https://hooks.slack.com/services/KEY"
340 assert json_response_and_validate_schema(conn, 200) == %{
351 "value" => [":none"],
356 "key" => ":webhook_url",
357 "value" => "https://hooks.slack.com/services/KEY",
358 "db" => [":webhook_url"]
363 assert Application.get_env(:quack, :level) == :info
364 assert Application.get_env(:quack, :meta) == [:none]
365 assert Application.get_env(:quack, :webhook_url) == "https://hooks.slack.com/services/KEY"
368 test "saving config with partial update", %{conn: conn} do
369 config = insert(:config, key: ":key1", value: :erlang.term_to_binary(key1: 1, key2: 2))
373 |> put_req_header("content-type", "application/json")
374 |> post("/api/pleroma/admin/config", %{
376 %{group: config.group, key: config.key, value: [%{"tuple" => [":key3", 3]}]}
380 assert json_response_and_validate_schema(conn, 200) == %{
383 "group" => ":pleroma",
386 %{"tuple" => [":key1", 1]},
387 %{"tuple" => [":key2", 2]},
388 %{"tuple" => [":key3", 3]}
390 "db" => [":key1", ":key2", ":key3"]
396 test "saving config which need pleroma reboot", %{conn: conn} do
397 chat = Config.get(:chat)
398 on_exit(fn -> Config.put(:chat, chat) end)
401 |> put_req_header("content-type", "application/json")
403 "/api/pleroma/admin/config",
406 %{group: ":pleroma", key: ":chat", value: [%{"tuple" => [":enabled", true]}]}
410 |> json_response_and_validate_schema(200) == %{
413 "db" => [":enabled"],
414 "group" => ":pleroma",
416 "value" => [%{"tuple" => [":enabled", true]}]
419 "need_reboot" => true
424 |> get("/api/pleroma/admin/config")
425 |> json_response_and_validate_schema(200)
427 assert configs["need_reboot"]
430 assert conn |> get("/api/pleroma/admin/restart") |> json_response(200) ==
432 end) =~ "pleroma restarted"
436 |> get("/api/pleroma/admin/config")
437 |> json_response_and_validate_schema(200)
439 assert configs["need_reboot"] == false
442 test "update setting which need reboot, don't change reboot flag until reboot", %{conn: conn} do
443 chat = Config.get(:chat)
444 on_exit(fn -> Config.put(:chat, chat) end)
447 |> put_req_header("content-type", "application/json")
449 "/api/pleroma/admin/config",
452 %{group: ":pleroma", key: ":chat", value: [%{"tuple" => [":enabled", true]}]}
456 |> json_response_and_validate_schema(200) == %{
459 "db" => [":enabled"],
460 "group" => ":pleroma",
462 "value" => [%{"tuple" => [":enabled", true]}]
465 "need_reboot" => true
469 |> put_req_header("content-type", "application/json")
470 |> post("/api/pleroma/admin/config", %{
472 %{group: ":pleroma", key: ":key1", value: [%{"tuple" => [":key3", 3]}]}
475 |> json_response_and_validate_schema(200) == %{
478 "group" => ":pleroma",
481 %{"tuple" => [":key3", 3]}
486 "need_reboot" => true
490 assert conn |> get("/api/pleroma/admin/restart") |> json_response(200) ==
492 end) =~ "pleroma restarted"
496 |> get("/api/pleroma/admin/config")
497 |> json_response_and_validate_schema(200)
499 assert configs["need_reboot"] == false
502 test "saving config with nested merge", %{conn: conn} do
504 insert(:config, key: ":key1", value: :erlang.term_to_binary(key1: 1, key2: [k1: 1, k2: 2]))
508 |> put_req_header("content-type", "application/json")
509 |> post("/api/pleroma/admin/config", %{
515 %{"tuple" => [":key3", 3]},
520 %{"tuple" => [":k2", 1]},
521 %{"tuple" => [":k3", 3]}
530 assert json_response_and_validate_schema(conn, 200) == %{
533 "group" => ":pleroma",
536 %{"tuple" => [":key1", 1]},
537 %{"tuple" => [":key3", 3]},
542 %{"tuple" => [":k1", 1]},
543 %{"tuple" => [":k2", 1]},
544 %{"tuple" => [":k3", 3]}
549 "db" => [":key1", ":key3", ":key2"]
555 test "saving special atoms", %{conn: conn} do
558 |> put_req_header("content-type", "application/json")
559 |> post("/api/pleroma/admin/config", %{
562 "group" => ":pleroma",
568 [%{"tuple" => [":versions", [":tlsv1", ":tlsv1.1", ":tlsv1.2"]]}]
576 assert json_response_and_validate_schema(conn, 200) == %{
579 "group" => ":pleroma",
585 [%{"tuple" => [":versions", [":tlsv1", ":tlsv1.1", ":tlsv1.2"]]}]
589 "db" => [":ssl_options"]
594 assert Application.get_env(:pleroma, :key1) == [
595 ssl_options: [versions: [:tlsv1, :"tlsv1.1", :"tlsv1.2"]]
599 test "saving full setting if value is in full_key_update list", %{conn: conn} do
600 backends = Application.get_env(:logger, :backends)
601 on_exit(fn -> Application.put_env(:logger, :backends, backends) end)
607 value: :erlang.term_to_binary([])
610 Pleroma.Config.TransferTask.load_and_update_env([], false)
612 assert Application.get_env(:logger, :backends) == []
616 |> put_req_header("content-type", "application/json")
617 |> post("/api/pleroma/admin/config", %{
627 assert json_response_and_validate_schema(conn, 200) == %{
630 "group" => ":logger",
631 "key" => ":backends",
635 "db" => [":backends"]
640 assert Application.get_env(:logger, :backends) == [
645 test "saving full setting if value is not keyword", %{conn: conn} do
650 value: :erlang.term_to_binary(Tesla.Adapter.Hackey)
655 |> put_req_header("content-type", "application/json")
656 |> post("/api/pleroma/admin/config", %{
658 %{group: config.group, key: config.key, value: "Tesla.Adapter.Httpc"}
662 assert json_response_and_validate_schema(conn, 200) == %{
667 "value" => "Tesla.Adapter.Httpc",
674 test "update config setting & delete with fallback to default value", %{
679 ueberauth = Application.get_env(:ueberauth, Ueberauth)
680 config1 = insert(:config, key: ":keyaa1")
681 config2 = insert(:config, key: ":keyaa2")
691 |> put_req_header("content-type", "application/json")
692 |> post("/api/pleroma/admin/config", %{
694 %{group: config1.group, key: config1.key, value: "another_value"},
695 %{group: config2.group, key: config2.key, value: "another_value"}
699 assert json_response_and_validate_schema(conn, 200) == %{
702 "group" => ":pleroma",
703 "key" => config1.key,
704 "value" => "another_value",
708 "group" => ":pleroma",
709 "key" => config2.key,
710 "value" => "another_value",
716 assert Application.get_env(:pleroma, :keyaa1) == "another_value"
717 assert Application.get_env(:pleroma, :keyaa2) == "another_value"
718 assert Application.get_env(:ueberauth, Ueberauth) == ConfigDB.from_binary(config3.value)
722 |> assign(:user, admin)
723 |> assign(:token, token)
724 |> put_req_header("content-type", "application/json")
725 |> post("/api/pleroma/admin/config", %{
727 %{group: config2.group, key: config2.key, delete: true},
736 assert json_response_and_validate_schema(conn, 200) == %{
740 assert Application.get_env(:ueberauth, Ueberauth) == ueberauth
741 refute Keyword.has_key?(Application.get_all_env(:pleroma), :keyaa2)
744 test "common config example", %{conn: conn} do
747 |> put_req_header("content-type", "application/json")
748 |> post("/api/pleroma/admin/config", %{
751 "group" => ":pleroma",
752 "key" => "Pleroma.Captcha.NotReal",
754 %{"tuple" => [":enabled", false]},
755 %{"tuple" => [":method", "Pleroma.Captcha.Kocaptcha"]},
756 %{"tuple" => [":seconds_valid", 60]},
757 %{"tuple" => [":path", ""]},
758 %{"tuple" => [":key1", nil]},
759 %{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]},
760 %{"tuple" => [":regex1", "~r/https:\/\/example.com/"]},
761 %{"tuple" => [":regex2", "~r/https:\/\/example.com/u"]},
762 %{"tuple" => [":regex3", "~r/https:\/\/example.com/i"]},
763 %{"tuple" => [":regex4", "~r/https:\/\/example.com/s"]},
764 %{"tuple" => [":name", "Pleroma"]}
770 assert Config.get([Pleroma.Captcha.NotReal, :name]) == "Pleroma"
772 assert json_response_and_validate_schema(conn, 200) == %{
775 "group" => ":pleroma",
776 "key" => "Pleroma.Captcha.NotReal",
778 %{"tuple" => [":enabled", false]},
779 %{"tuple" => [":method", "Pleroma.Captcha.Kocaptcha"]},
780 %{"tuple" => [":seconds_valid", 60]},
781 %{"tuple" => [":path", ""]},
782 %{"tuple" => [":key1", nil]},
783 %{"tuple" => [":partial_chain", "&:hackney_connect.partial_chain/1"]},
784 %{"tuple" => [":regex1", "~r/https:\\/\\/example.com/"]},
785 %{"tuple" => [":regex2", "~r/https:\\/\\/example.com/u"]},
786 %{"tuple" => [":regex3", "~r/https:\\/\\/example.com/i"]},
787 %{"tuple" => [":regex4", "~r/https:\\/\\/example.com/s"]},
788 %{"tuple" => [":name", "Pleroma"]}
808 test "tuples with more than two values", %{conn: conn} do
811 |> put_req_header("content-type", "application/json")
812 |> post("/api/pleroma/admin/config", %{
815 "group" => ":pleroma",
816 "key" => "Pleroma.Web.Endpoint.NotReal",
833 "Pleroma.Web.MastodonAPI.WebsocketHandler",
840 "Phoenix.Endpoint.CowboyWebSocket",
843 "Phoenix.Transports.WebSocket",
846 "Pleroma.Web.Endpoint",
847 "Pleroma.Web.UserSocket",
858 "Phoenix.Endpoint.Cowboy2Handler",
859 %{"tuple" => ["Pleroma.Web.Endpoint", []]}
876 assert json_response_and_validate_schema(conn, 200) == %{
879 "group" => ":pleroma",
880 "key" => "Pleroma.Web.Endpoint.NotReal",
897 "Pleroma.Web.MastodonAPI.WebsocketHandler",
904 "Phoenix.Endpoint.CowboyWebSocket",
907 "Phoenix.Transports.WebSocket",
910 "Pleroma.Web.Endpoint",
911 "Pleroma.Web.UserSocket",
922 "Phoenix.Endpoint.Cowboy2Handler",
923 %{"tuple" => ["Pleroma.Web.Endpoint", []]}
942 test "settings with nesting map", %{conn: conn} do
945 |> put_req_header("content-type", "application/json")
946 |> post("/api/pleroma/admin/config", %{
949 "group" => ":pleroma",
952 %{"tuple" => [":key2", "some_val"]},
957 ":max_options" => 20,
958 ":max_option_chars" => 200,
959 ":min_expiration" => 0,
960 ":max_expiration" => 31_536_000,
962 ":max_options" => 20,
963 ":max_option_chars" => 200,
964 ":min_expiration" => 0,
965 ":max_expiration" => 31_536_000
975 assert json_response_and_validate_schema(conn, 200) ==
979 "group" => ":pleroma",
982 %{"tuple" => [":key2", "some_val"]},
987 ":max_expiration" => 31_536_000,
988 ":max_option_chars" => 200,
989 ":max_options" => 20,
990 ":min_expiration" => 0,
992 ":max_expiration" => 31_536_000,
993 ":max_option_chars" => 200,
994 ":max_options" => 20,
995 ":min_expiration" => 0
1001 "db" => [":key2", ":key3"]
1007 test "value as map", %{conn: conn} do
1010 |> put_req_header("content-type", "application/json")
1011 |> post("/api/pleroma/admin/config", %{
1014 "group" => ":pleroma",
1016 "value" => %{"key" => "some_val"}
1021 assert json_response_and_validate_schema(conn, 200) ==
1025 "group" => ":pleroma",
1027 "value" => %{"key" => "some_val"},
1034 test "queues key as atom", %{conn: conn} do
1037 |> put_req_header("content-type", "application/json")
1038 |> post("/api/pleroma/admin/config", %{
1044 %{"tuple" => [":federator_incoming", 50]},
1045 %{"tuple" => [":federator_outgoing", 50]},
1046 %{"tuple" => [":web_push", 50]},
1047 %{"tuple" => [":mailer", 10]},
1048 %{"tuple" => [":transmogrifier", 20]},
1049 %{"tuple" => [":scheduled_activities", 10]},
1050 %{"tuple" => [":background", 5]}
1056 assert json_response_and_validate_schema(conn, 200) == %{
1062 %{"tuple" => [":federator_incoming", 50]},
1063 %{"tuple" => [":federator_outgoing", 50]},
1064 %{"tuple" => [":web_push", 50]},
1065 %{"tuple" => [":mailer", 10]},
1066 %{"tuple" => [":transmogrifier", 20]},
1067 %{"tuple" => [":scheduled_activities", 10]},
1068 %{"tuple" => [":background", 5]}
1071 ":federator_incoming",
1072 ":federator_outgoing",
1076 ":scheduled_activities",
1084 test "delete part of settings by atom subkeys", %{conn: conn} do
1088 value: :erlang.term_to_binary(subkey1: "val1", subkey2: "val2", subkey3: "val3")
1093 |> put_req_header("content-type", "application/json")
1094 |> post("/api/pleroma/admin/config", %{
1097 group: config.group,
1099 subkeys: [":subkey1", ":subkey3"],
1105 assert json_response_and_validate_schema(conn, 200) == %{
1108 "group" => ":pleroma",
1110 "value" => [%{"tuple" => [":subkey2", "val2"]}],
1111 "db" => [":subkey2"]
1117 test "proxy tuple localhost", %{conn: conn} do
1120 |> put_req_header("content-type", "application/json")
1121 |> post("/api/pleroma/admin/config", %{
1127 %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]}
1136 "group" => ":pleroma",
1142 } = json_response_and_validate_schema(conn, 200)
1144 assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "localhost", 1234]}]} in value
1145 assert ":proxy_url" in db
1148 test "proxy tuple domain", %{conn: conn} do
1151 |> put_req_header("content-type", "application/json")
1152 |> post("/api/pleroma/admin/config", %{
1158 %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]}
1167 "group" => ":pleroma",
1173 } = json_response_and_validate_schema(conn, 200)
1175 assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "domain.com", 1234]}]} in value
1176 assert ":proxy_url" in db
1179 test "proxy tuple ip", %{conn: conn} do
1182 |> put_req_header("content-type", "application/json")
1183 |> post("/api/pleroma/admin/config", %{
1189 %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]}
1198 "group" => ":pleroma",
1204 } = json_response_and_validate_schema(conn, 200)
1206 assert %{"tuple" => [":proxy_url", %{"tuple" => [":socks5", "127.0.0.1", 1234]}]} in value
1207 assert ":proxy_url" in db
1210 @tag capture_log: true
1211 test "doesn't set keys not in the whitelist", %{conn: conn} do
1212 clear_config(:database_config_whitelist, [
1215 {:pleroma, Pleroma.Captcha.NotReal},
1220 |> put_req_header("content-type", "application/json")
1221 |> post("/api/pleroma/admin/config", %{
1223 %{group: ":pleroma", key: ":key1", value: "value1"},
1224 %{group: ":pleroma", key: ":key2", value: "value2"},
1225 %{group: ":pleroma", key: ":key3", value: "value3"},
1226 %{group: ":pleroma", key: "Pleroma.Web.Endpoint.NotReal", value: "value4"},
1227 %{group: ":pleroma", key: "Pleroma.Captcha.NotReal", value: "value5"},
1228 %{group: ":not_real", key: ":anything", value: "value6"}
1232 assert Application.get_env(:pleroma, :key1) == "value1"
1233 assert Application.get_env(:pleroma, :key2) == "value2"
1234 assert Application.get_env(:pleroma, :key3) == nil
1235 assert Application.get_env(:pleroma, Pleroma.Web.Endpoint.NotReal) == nil
1236 assert Application.get_env(:pleroma, Pleroma.Captcha.NotReal) == "value5"
1237 assert Application.get_env(:not_real, :anything) == "value6"
1241 describe "GET /api/pleroma/admin/config/descriptions" do
1242 test "structure", %{conn: conn} do
1243 admin = insert(:user, is_admin: true)
1246 assign(conn, :user, admin)
1247 |> get("/api/pleroma/admin/config/descriptions")
1249 assert [child | _others] = json_response_and_validate_schema(conn, 200)
1251 assert child["children"]
1253 assert String.starts_with?(child["group"], ":")
1254 assert child["description"]
1257 test "filters by database configuration whitelist", %{conn: conn} do
1258 clear_config(:database_config_whitelist, [
1259 {:pleroma, :instance},
1260 {:pleroma, :activitypub},
1261 {:pleroma, Pleroma.Upload},
1265 admin = insert(:user, is_admin: true)
1268 assign(conn, :user, admin)
1269 |> get("/api/pleroma/admin/config/descriptions")
1271 children = json_response_and_validate_schema(conn, 200)
1273 assert length(children) == 4
1275 assert Enum.count(children, fn c -> c["group"] == ":pleroma" end) == 3
1277 instance = Enum.find(children, fn c -> c["key"] == ":instance" end)
1278 assert instance["children"]
1280 activitypub = Enum.find(children, fn c -> c["key"] == ":activitypub" end)
1281 assert activitypub["children"]
1283 web_endpoint = Enum.find(children, fn c -> c["key"] == "Pleroma.Upload" end)
1284 assert web_endpoint["children"]
1286 esshd = Enum.find(children, fn c -> c["group"] == ":esshd" end)
1287 assert esshd["children"]