X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Fadmin_api%2Fcontrollers%2Fmedia_proxy_cache_controller_test.exs;h=30e941869f10d906c6ca702600eb50080be43ea1;hb=07a48b9293e4046c50b5d424d60a1bf16c7cc198;hp=db935ad128c1a9063a8e2329fcec17ce4aa8c445;hpb=e3508988283a0902a7e330995a0c224811956bce;p=akkoma diff --git a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs index db935ad12..30e941869 100644 --- a/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs +++ b/test/pleroma/web/admin_api/controllers/media_proxy_cache_controller_test.exs @@ -21,14 +21,14 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do |> assign(:user, admin) |> assign(:token, token) - Config.put([:media_proxy, :enabled], true) - Config.put([:media_proxy, :invalidation, :enabled], true) - Config.put([:media_proxy, :invalidation, :provider], MediaProxy.Invalidation.Script) + clear_config([:media_proxy, :enabled], true) + clear_config([:media_proxy, :invalidation, :enabled], true) + clear_config([:media_proxy, :invalidation, :provider], MediaProxy.Invalidation.Script) {:ok, %{admin: admin, token: token, conn: conn}} end - describe "GET /api/pleroma/admin/media_proxy_caches" do + describe "GET /api/v1/pleroma/admin/media_proxy_caches" do test "shows banned MediaProxy URLs", %{conn: conn} do MediaProxy.put_in_banned_urls([ "http://localhost:4001/media/a688346.jpg", @@ -41,36 +41,40 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do response = conn - |> get("/api/pleroma/admin/media_proxy_caches?page_size=2") + |> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2") |> json_response_and_validate_schema(200) assert response["page_size"] == 2 assert response["count"] == 5 - assert response["urls"] == [ - "http://localhost:4001/media/fb1f4d.jpg", - "http://localhost:4001/media/a688346.jpg" - ] + results = response["urls"] response = conn - |> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=2") + |> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&page=2") |> json_response_and_validate_schema(200) - assert response["urls"] == [ - "http://localhost:4001/media/gb1f44.jpg", - "http://localhost:4001/media/tb13f47.jpg" - ] - assert response["page_size"] == 2 assert response["count"] == 5 + results = results ++ response["urls"] + response = conn - |> get("/api/pleroma/admin/media_proxy_caches?page_size=2&page=3") + |> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&page=3") |> json_response_and_validate_schema(200) - assert response["urls"] == ["http://localhost:4001/media/wb1f46.jpg"] + results = results ++ response["urls"] + + assert results |> Enum.sort() == + [ + "http://localhost:4001/media/wb1f46.jpg", + "http://localhost:4001/media/gb1f44.jpg", + "http://localhost:4001/media/tb13f47.jpg", + "http://localhost:4001/media/fb1f4d.jpg", + "http://localhost:4001/media/a688346.jpg" + ] + |> Enum.sort() end test "search banned MediaProxy URLs", %{conn: conn} do @@ -85,12 +89,12 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do response = conn - |> get("/api/pleroma/admin/media_proxy_caches?page_size=2&query=F44") + |> get("/api/v1/pleroma/admin/media_proxy_caches?page_size=2&query=F44") |> json_response_and_validate_schema(200) - assert response["urls"] == [ - "http://localhost:4001/media/gb1f44.jpg", - "http://localhost:4001/media/ff44b1f4d.jpg" + assert response["urls"] |> Enum.sort() == [ + "http://localhost:4001/media/ff44b1f4d.jpg", + "http://localhost:4001/media/gb1f44.jpg" ] assert response["page_size"] == 2 @@ -98,7 +102,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do end end - describe "POST /api/pleroma/admin/media_proxy_caches/delete" do + describe "POST /api/v1/pleroma/admin/media_proxy_caches/delete" do test "deleted MediaProxy URLs from banned", %{conn: conn} do MediaProxy.put_in_banned_urls([ "http://localhost:4001/media/a688346.jpg", @@ -107,7 +111,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do conn |> put_req_header("content-type", "application/json") - |> post("/api/pleroma/admin/media_proxy_caches/delete", %{ + |> post("/api/v1/pleroma/admin/media_proxy_caches/delete", %{ urls: ["http://localhost:4001/media/a688346.jpg"] }) |> json_response_and_validate_schema(200) @@ -117,7 +121,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do end end - describe "POST /api/pleroma/admin/media_proxy_caches/purge" do + describe "POST /api/v1/pleroma/admin/media_proxy_caches/purge" do test "perform invalidates cache of MediaProxy", %{conn: conn} do urls = [ "http://example.com/media/a688346.jpg", @@ -132,7 +136,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do ] do conn |> put_req_header("content-type", "application/json") - |> post("/api/pleroma/admin/media_proxy_caches/purge", %{urls: urls, ban: false}) + |> post("/api/v1/pleroma/admin/media_proxy_caches/purge", %{urls: urls, ban: false}) |> json_response_and_validate_schema(200) refute MediaProxy.in_banned_urls("http://example.com/media/a688346.jpg") @@ -150,7 +154,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do conn |> put_req_header("content-type", "application/json") |> post( - "/api/pleroma/admin/media_proxy_caches/purge", + "/api/v1/pleroma/admin/media_proxy_caches/purge", %{urls: urls, ban: true} ) |> json_response_and_validate_schema(200)