summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2021-04-13 10:52:53 -0500
committerMark Felder <feld@feld.me>2021-04-13 10:52:53 -0500
commit9fbcdc15b11dedf27bc5c78d09048ba354906c16 (patch)
tree67f0eb373139b6927d2889fdbe133b75e548aaed
parent0feafcc20cec168258f592b9d509c1e6ccc8efba (diff)
Validate custom instance thumbnail set via AdminAPI produces correct URL
-rw-r--r--CHANGELOG.md1
-rw-r--r--test/pleroma/web/admin_api/controllers/config_controller_test.exs42
2 files changed, 43 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c45cad85..1553245e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Try to save exported ConfigDB settings (migrate_from_db) in the system temp directory if default location is not writable.
+- Uploading custom instance thumbnail via AdminAPI/AdminFE generated invalid URL to the image
## [2.3.0] - 2020-03-01
diff --git a/test/pleroma/web/admin_api/controllers/config_controller_test.exs b/test/pleroma/web/admin_api/controllers/config_controller_test.exs
index 578a4c914..71151712e 100644
--- a/test/pleroma/web/admin_api/controllers/config_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/config_controller_test.exs
@@ -1410,6 +1410,48 @@ defmodule Pleroma.Web.AdminAPI.ConfigControllerTest do
"need_reboot" => false
}
end
+
+ test "custom instance thumbnail", %{conn: conn} do
+ clear_config([:instance])
+
+ params = %{
+ "group" => ":pleroma",
+ "key" => ":instance",
+ "value" => [
+ %{
+ "tuple" => [
+ ":instance_thumbnail",
+ "https://example.com/media/new_thumbnail.jpg"
+ ]
+ }
+ ]
+ }
+
+ res =
+ assert conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/pleroma/admin/config", %{"configs" => [params]})
+ |> json_response_and_validate_schema(200)
+
+ assert res == %{
+ "configs" => [
+ %{
+ "db" => [":instance_thumbnail"],
+ "group" => ":pleroma",
+ "key" => ":instance",
+ "value" => params["value"]
+ }
+ ],
+ "need_reboot" => false
+ }
+
+ assert res =
+ conn
+ |> get("/api/v1/instance")
+ |> json_response_and_validate_schema(200)
+
+ assert res = %{"thumbnail" => "https://example.com/media/new_thumbnail.jpg"}
+ end
end
describe "GET /api/pleroma/admin/config/descriptions" do