X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fadmin_api%2Fcontrollers%2Ffrontend_controller_test.exs;h=bc827cc12ee48cb2f10905ca66864b29346ac7b9;hb=85d71d4f1d433a168eb136ad88b651b6c1d1a4fc;hp=1d4fbfa03bd3c7df8de46aa569f4a5f5710f029f;hpb=435bf1f9450954eab5f753a983dee202aa11bac1;p=akkoma
diff --git a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
index 1d4fbfa03..bc827cc12 100644
--- a/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
+++ b/test/pleroma/web/admin_api/controllers/frontend_controller_test.exs
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
@@ -44,7 +44,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
end
end
- describe "POST /api/pleroma/admin/frontends" do
+ describe "POST /api/pleroma/admin/frontends/install" do
test "from available frontends", %{conn: conn} do
clear_config([:frontends, :available], %{
"pleroma" => %{
@@ -60,7 +60,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends", %{name: "pleroma"})
+ |> post("/api/pleroma/admin/frontends/install", %{name: "pleroma"})
|> json_response_and_validate_schema(:ok)
assert File.exists?(Path.join([@dir, "frontends", "pleroma", "fantasy", "test.txt"]))
@@ -92,7 +92,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends", %{
+ |> post("/api/pleroma/admin/frontends/install", %{
name: "pleroma",
file: "test/fixtures/tesla_mock/frontend.zip"
})
@@ -108,7 +108,7 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
conn
|> put_req_header("content-type", "application/json")
- |> post("/api/pleroma/admin/frontends", %{
+ |> post("/api/pleroma/admin/frontends/install", %{
name: "unknown",
ref: "baka",
build_url: "http://gensokyo.2hu/madeup.zip",
@@ -118,5 +118,24 @@ defmodule Pleroma.Web.AdminAPI.FrontendControllerTest do
assert File.exists?(Path.join([@dir, "frontends", "unknown", "baka", "test.txt"]))
end
+
+ test "failing returns an error", %{conn: conn} do
+ Tesla.Mock.mock(fn %{url: "http://gensokyo.2hu/madeup.zip"} ->
+ %Tesla.Env{status: 404, body: ""}
+ end)
+
+ result =
+ conn
+ |> put_req_header("content-type", "application/json")
+ |> post("/api/pleroma/admin/frontends/install", %{
+ name: "unknown",
+ ref: "baka",
+ build_url: "http://gensokyo.2hu/madeup.zip",
+ build_dir: ""
+ })
+ |> json_response_and_validate_schema(400)
+
+ assert result == %{"error" => "Could not download or unzip the frontend"}
+ end
end
end