ConfigDB: Don't use a different config whitelist globally in tests
This commit is contained in:
parent
41ab347571
commit
a89fe828d3
1 changed files with 62 additions and 69 deletions
|
|
@ -194,19 +194,9 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|
|
||||||
setup do: clear_config(:configurable_from_database, true)
|
setup do: clear_config(:configurable_from_database, true)
|
||||||
|
|
||||||
setup do:
|
|
||||||
clear_config(:database_config_whitelist, [
|
|
||||||
{:pleroma},
|
|
||||||
{:http},
|
|
||||||
{:idna},
|
|
||||||
{:oban},
|
|
||||||
{:tesla},
|
|
||||||
{:ueberauth}
|
|
||||||
])
|
|
||||||
|
|
||||||
test "create new config setting in db", %{conn: conn} do
|
test "create new config setting in db", %{conn: conn} do
|
||||||
ueberauth = Application.get_env(:ueberauth, Ueberauth)
|
aws = Application.get_env(:ex_aws, :s3)
|
||||||
on_exit(fn -> Application.put_env(:ueberauth, Ueberauth, ueberauth) end)
|
on_exit(fn -> Application.put_env(:ex_aws, :s3, aws) end)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
conn
|
conn
|
||||||
|
|
@ -215,9 +205,9 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
configs: [
|
configs: [
|
||||||
%{group: ":pleroma", key: ":key1", value: "value1"},
|
%{group: ":pleroma", key: ":key1", value: "value1"},
|
||||||
%{
|
%{
|
||||||
group: ":ueberauth",
|
group: ":cors_plug",
|
||||||
key: "Ueberauth",
|
key: ":key1",
|
||||||
value: [%{"tuple" => [":consumer_secret", "aaaa"]}]
|
value: [%{"tuple" => [":key", "value"]}]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: ":pleroma",
|
group: ":pleroma",
|
||||||
|
|
@ -244,9 +234,9 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
value: %{":nested_5" => ":upload", "endpoint" => "https://example.com"}
|
value: %{":nested_5" => ":upload", "endpoint" => "https://example.com"}
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: ":idna",
|
group: ":ex_aws",
|
||||||
key: ":key5",
|
key: ":s3",
|
||||||
value: %{"tuple" => ["string", "Pleroma.Captcha.NotReal", []]}
|
value: %{"tuple" => ["access_key_id", "aaaa", []]}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
@ -260,10 +250,10 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
"db" => [":key1"]
|
"db" => [":key1"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"group" => ":ueberauth",
|
"group" => ":cors_plug",
|
||||||
"key" => "Ueberauth",
|
"key" => ":key1",
|
||||||
"value" => [%{"tuple" => [":consumer_secret", "aaaa"]}],
|
"value" => [%{"tuple" => [":key", "value"]}],
|
||||||
"db" => [":consumer_secret"]
|
"db" => [":key"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"group" => ":pleroma",
|
"group" => ":pleroma",
|
||||||
|
|
@ -293,10 +283,10 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
"db" => [":key4"]
|
"db" => [":key4"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"group" => ":idna",
|
"group" => ":ex_aws",
|
||||||
"key" => ":key5",
|
"key" => ":s3",
|
||||||
"value" => %{"tuple" => ["string", "Pleroma.Captcha.NotReal", []]},
|
"value" => %{"tuple" => ["access_key_id", "aaaa", []]},
|
||||||
"db" => [":key5"]
|
"db" => [":s3"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"need_reboot" => false
|
"need_reboot" => false
|
||||||
|
|
@ -322,18 +312,19 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
nested_5: :upload
|
nested_5: :upload
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Application.get_env(:idna, :key5) == {"string", Pleroma.Captcha.NotReal, []}
|
assert Application.get_env(:cors_plug, :key1) == [key: "value"]
|
||||||
|
assert Application.get_env(:ex_aws, :s3) == {"access_key_id", "aaaa", []}
|
||||||
end
|
end
|
||||||
|
|
||||||
test "save configs setting without explicit key", %{conn: conn} do
|
test "save configs setting without explicit key", %{conn: conn} do
|
||||||
adapter = Application.get_env(:http, :adapter)
|
mime = Application.get_env(:mime, :library)
|
||||||
send_user_agent = Application.get_env(:http, :send_user_agent)
|
prometheus = Application.get_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter)
|
||||||
user_agent = Application.get_env(:http, :user_agent)
|
web_push = Application.get_env(:web_push_encryption, :vapid_details)
|
||||||
|
|
||||||
on_exit(fn ->
|
on_exit(fn ->
|
||||||
Application.put_env(:http, :adapter, adapter)
|
Application.put_env(:mime, :library, mime)
|
||||||
Application.put_env(:http, :send_user_agent, send_user_agent)
|
Application.put_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter, prometheus)
|
||||||
Application.put_env(:http, :user_agent, user_agent)
|
Application.put_env(:web_push_encryption, :vapid_details, web_push)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
|
|
@ -342,19 +333,19 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|> post("/api/pleroma/admin/config", %{
|
|> post("/api/pleroma/admin/config", %{
|
||||||
configs: [
|
configs: [
|
||||||
%{
|
%{
|
||||||
group: ":http",
|
group: ":mime",
|
||||||
key: ":adapter",
|
key: ":library",
|
||||||
value: [":someval"]
|
value: [":someval"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: ":http",
|
group: ":prometheus",
|
||||||
key: ":send_user_agent",
|
key: "Pleroma.Web.Endpoint.MetricsExporter",
|
||||||
value: true
|
value: true
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
group: ":http",
|
group: ":web_push_encryption",
|
||||||
key: ":user_agent",
|
key: ":vapid_details",
|
||||||
value: [":default"]
|
value: [":nope"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
@ -362,30 +353,30 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
assert json_response_and_validate_schema(conn, 200) == %{
|
assert json_response_and_validate_schema(conn, 200) == %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":http",
|
"group" => ":mime",
|
||||||
"key" => ":adapter",
|
"key" => ":library",
|
||||||
"value" => [":someval"],
|
"value" => [":someval"],
|
||||||
"db" => [":adapter"]
|
"db" => [":library"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"group" => ":http",
|
"group" => ":prometheus",
|
||||||
"key" => ":send_user_agent",
|
"key" => "Pleroma.Web.Endpoint.MetricsExporter",
|
||||||
"value" => true,
|
"value" => true,
|
||||||
"db" => [":send_user_agent"]
|
"db" => ["Pleroma.Web.Endpoint.MetricsExporter"]
|
||||||
},
|
},
|
||||||
%{
|
%{
|
||||||
"group" => ":http",
|
"group" => ":web_push_encryption",
|
||||||
"key" => ":user_agent",
|
"key" => ":vapid_details",
|
||||||
"value" => [":default"],
|
"value" => [":nope"],
|
||||||
"db" => [":user_agent"]
|
"db" => [":vapid_details"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"need_reboot" => false
|
"need_reboot" => false
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Application.get_env(:http, :adapter) == [:someval]
|
assert Application.get_env(:mime, :library) == [:someval]
|
||||||
assert Application.get_env(:http, :send_user_agent) == true
|
assert Application.get_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter) == true
|
||||||
assert Application.get_env(:http, :user_agent) == [:default]
|
assert Application.get_env(:web_push_encryption, :vapid_details) == [:nope]
|
||||||
end
|
end
|
||||||
|
|
||||||
test "saving config with partial update", %{conn: conn} do
|
test "saving config with partial update", %{conn: conn} do
|
||||||
|
|
@ -631,17 +622,17 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|> put_req_header("content-type", "application/json")
|
|> put_req_header("content-type", "application/json")
|
||||||
|> post("/api/pleroma/admin/config", %{
|
|> post("/api/pleroma/admin/config", %{
|
||||||
configs: [
|
configs: [
|
||||||
%{group: ":tesla", key: ":adapter", value: "Tesla.Adapter.Httpc"}
|
%{group: ":pleroma", key: ":key1", value: "Pleroma.Web.Endpoint"}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
assert json_response_and_validate_schema(conn, 200) == %{
|
assert json_response_and_validate_schema(conn, 200) == %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":tesla",
|
"group" => ":pleroma",
|
||||||
"key" => ":adapter",
|
"key" => ":key1",
|
||||||
"value" => "Tesla.Adapter.Httpc",
|
"value" => "Pleroma.Web.Endpoint",
|
||||||
"db" => [":adapter"]
|
"db" => [":key1"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"need_reboot" => false
|
"need_reboot" => false
|
||||||
|
|
@ -653,14 +644,14 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
admin: admin,
|
admin: admin,
|
||||||
token: token
|
token: token
|
||||||
} do
|
} do
|
||||||
ueberauth = Application.get_env(:ueberauth, Ueberauth)
|
prometheus = Application.get_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter)
|
||||||
insert(:config, key: :keyaa1)
|
insert(:config, key: :keyaa1)
|
||||||
insert(:config, key: :keyaa2)
|
insert(:config, key: :keyaa2)
|
||||||
|
|
||||||
config3 =
|
config3 =
|
||||||
insert(:config,
|
insert(:config,
|
||||||
group: :ueberauth,
|
group: :prometheus,
|
||||||
key: Ueberauth
|
key: Pleroma.Web.Endpoint.MetricsExporter
|
||||||
)
|
)
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
|
|
@ -693,7 +684,9 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|
|
||||||
assert Application.get_env(:pleroma, :keyaa1) == "another_value"
|
assert Application.get_env(:pleroma, :keyaa1) == "another_value"
|
||||||
assert Application.get_env(:pleroma, :keyaa2) == "another_value"
|
assert Application.get_env(:pleroma, :keyaa2) == "another_value"
|
||||||
assert Application.get_env(:ueberauth, Ueberauth) == config3.value
|
|
||||||
|
assert Application.get_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter) ==
|
||||||
|
config3.value
|
||||||
|
|
||||||
conn =
|
conn =
|
||||||
build_conn()
|
build_conn()
|
||||||
|
|
@ -704,8 +697,8 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
configs: [
|
configs: [
|
||||||
%{group: ":pleroma", key: ":keyaa2", delete: true},
|
%{group: ":pleroma", key: ":keyaa2", delete: true},
|
||||||
%{
|
%{
|
||||||
group: ":ueberauth",
|
group: ":prometheus",
|
||||||
key: "Ueberauth",
|
key: "Pleroma.Web.Endpoint.MetricsExporter",
|
||||||
delete: true
|
delete: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -716,7 +709,7 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
"need_reboot" => false
|
"need_reboot" => false
|
||||||
}
|
}
|
||||||
|
|
||||||
assert Application.get_env(:ueberauth, Ueberauth) == ueberauth
|
assert Application.get_env(:prometheus, Pleroma.Web.Endpoint.MetricsExporter) == prometheus
|
||||||
refute Keyword.has_key?(Application.get_all_env(:pleroma), :keyaa2)
|
refute Keyword.has_key?(Application.get_all_env(:pleroma), :keyaa2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -1021,8 +1014,8 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
|> post("/api/pleroma/admin/config", %{
|
|> post("/api/pleroma/admin/config", %{
|
||||||
configs: [
|
configs: [
|
||||||
%{
|
%{
|
||||||
"group" => ":oban",
|
"group" => ":pleroma",
|
||||||
"key" => ":queues",
|
"key" => ":nonexist_oban_queues",
|
||||||
"value" => [
|
"value" => [
|
||||||
%{"tuple" => [":federator_incoming", 50]},
|
%{"tuple" => [":federator_incoming", 50]},
|
||||||
%{"tuple" => [":federator_outgoing", 50]},
|
%{"tuple" => [":federator_outgoing", 50]},
|
||||||
|
|
@ -1039,8 +1032,8 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
|
||||||
assert json_response_and_validate_schema(conn, 200) == %{
|
assert json_response_and_validate_schema(conn, 200) == %{
|
||||||
"configs" => [
|
"configs" => [
|
||||||
%{
|
%{
|
||||||
"group" => ":oban",
|
"group" => ":pleroma",
|
||||||
"key" => ":queues",
|
"key" => ":nonexist_oban_queues",
|
||||||
"value" => [
|
"value" => [
|
||||||
%{"tuple" => [":federator_incoming", 50]},
|
%{"tuple" => [":federator_incoming", 50]},
|
||||||
%{"tuple" => [":federator_outgoing", 50]},
|
%{"tuple" => [":federator_outgoing", 50]},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue