Merge branch 'issue/1855' into 'develop'
[akkoma] / test / web / admin_api / controllers / media_proxy_cache_controller_test.exs
index 76a96f46f0f902a09d8ed0807cdf14fbe2c9c71c..5ab6cb78a0255ba4a844476770c4bd8c7463de1e 100644 (file)
@@ -13,8 +13,7 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
   setup do: clear_config([:media_proxy])
 
   setup do
-    on_exit(fn -> Cachex.clear(:deleted_urls_cache) end)
-    :ok
+    on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
   end
 
   setup do
@@ -35,14 +34,14 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
 
   describe "GET /api/pleroma/admin/media_proxy_caches" do
     test "shows banned MediaProxy URLs", %{conn: conn} do
-      MediaProxy.put_in_deleted_urls([
+      MediaProxy.put_in_banned_urls([
         "http://localhost:4001/media/a688346.jpg",
         "http://localhost:4001/media/fb1f4d.jpg"
       ])
 
-      MediaProxy.put_in_deleted_urls("http://localhost:4001/media/gb1f44.jpg")
-      MediaProxy.put_in_deleted_urls("http://localhost:4001/media/tb13f47.jpg")
-      MediaProxy.put_in_deleted_urls("http://localhost:4001/media/wb1f46.jpg")
+      MediaProxy.put_in_banned_urls("http://localhost:4001/media/gb1f44.jpg")
+      MediaProxy.put_in_banned_urls("http://localhost:4001/media/tb13f47.jpg")
+      MediaProxy.put_in_banned_urls("http://localhost:4001/media/wb1f46.jpg")
 
       response =
         conn
@@ -73,9 +72,9 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
     end
   end
 
-  describe "DELETE /api/pleroma/admin/media_proxy_caches/delete" do
+  describe "POST /api/pleroma/admin/media_proxy_caches/delete" do
     test "deleted MediaProxy URLs from banned", %{conn: conn} do
-      MediaProxy.put_in_deleted_urls([
+      MediaProxy.put_in_banned_urls([
         "http://localhost:4001/media/a688346.jpg",
         "http://localhost:4001/media/fb1f4d.jpg"
       ])
@@ -89,12 +88,12 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
         |> json_response_and_validate_schema(200)
 
       assert response["urls"] == ["http://localhost:4001/media/a688346.jpg"]
-      refute MediaProxy.in_deleted_urls("http://localhost:4001/media/a688346.jpg")
-      assert MediaProxy.in_deleted_urls("http://localhost:4001/media/fb1f4d.jpg")
+      refute MediaProxy.in_banned_urls("http://localhost:4001/media/a688346.jpg")
+      assert MediaProxy.in_banned_urls("http://localhost:4001/media/fb1f4d.jpg")
     end
   end
 
-  describe "PURGE /api/pleroma/admin/media_proxy_caches/purge" do
+  describe "POST /api/pleroma/admin/media_proxy_caches/purge" do
     test "perform invalidates cache of MediaProxy", %{conn: conn} do
       urls = [
         "http://example.com/media/a688346.jpg",
@@ -115,8 +114,8 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
 
         assert response["urls"] == urls
 
-        refute MediaProxy.in_deleted_urls("http://example.com/media/a688346.jpg")
-        refute MediaProxy.in_deleted_urls("http://example.com/media/fb1f4d.jpg")
+        refute MediaProxy.in_banned_urls("http://example.com/media/a688346.jpg")
+        refute MediaProxy.in_banned_urls("http://example.com/media/fb1f4d.jpg")
       end
     end
 
@@ -138,8 +137,8 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
 
         assert response["urls"] == urls
 
-        assert MediaProxy.in_deleted_urls("http://example.com/media/a688346.jpg")
-        assert MediaProxy.in_deleted_urls("http://example.com/media/fb1f4d.jpg")
+        assert MediaProxy.in_banned_urls("http://example.com/media/a688346.jpg")
+        assert MediaProxy.in_banned_urls("http://example.com/media/fb1f4d.jpg")
       end
     end
   end