Merge branch 'fix-tests' into 'develop'
Test fixes See merge request pleroma/pleroma!3532
This commit is contained in:
commit
4d341f51e1
4 changed files with 27 additions and 20 deletions
|
|
@ -9,11 +9,6 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
|
|||
alias Pleroma.Emoji
|
||||
alias Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy
|
||||
|
||||
setup_all do
|
||||
Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||
:ok
|
||||
end
|
||||
|
||||
setup do
|
||||
emoji_path = [:instance, :static_dir] |> Config.get() |> Path.join("emoji/stolen")
|
||||
|
||||
|
|
@ -49,6 +44,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
|
|||
refute "firedfox" in installed()
|
||||
refute File.exists?(path)
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: "https://example.org/emoji/firedfox.png"} ->
|
||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}
|
||||
end)
|
||||
|
||||
clear_config(:mrf_steal_emoji, hosts: ["example.org"], size_limit: 284_468)
|
||||
|
||||
assert {:ok, _message} = StealEmojiPolicy.filter(message)
|
||||
|
|
@ -78,6 +77,10 @@ defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
|
|||
test "reject if size is above the limit", %{message: message} do
|
||||
refute "firedfox" in installed()
|
||||
|
||||
Tesla.Mock.mock(fn %{method: :get, url: "https://example.org/emoji/firedfox.png"} ->
|
||||
%Tesla.Env{status: 200, body: File.read!("test/fixtures/image.jpg")}
|
||||
end)
|
||||
|
||||
clear_config(:mrf_steal_emoji, hosts: ["example.org"], size_limit: 50_000)
|
||||
|
||||
assert {:ok, _message} = StealEmojiPolicy.filter(message)
|
||||
|
|
|
|||
|
|
@ -47,30 +47,34 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
|
|||
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")
|
||||
|> 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")
|
||||
|> 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
|
||||
|
|
@ -88,9 +92,9 @@ defmodule Pleroma.Web.AdminAPI.MediaProxyCacheControllerTest do
|
|||
|> get("/api/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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue