X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fpleroma%2Fweb%2Factivity_pub%2Fmrf%2Fsteal_emoji_policy_test.exs;h=1b37e4c26dd635e196cda3984cea394cf3692a1b;hb=4d341f51e17c36f8c59246d9b7dc5d8793b9fd78;hp=7665d00d0c2e1dadfdf9c6d75a248b30ad1b3520;hpb=c2186a62d54043ea9638d33f80c7576aba9783e8;p=akkoma diff --git a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs index 7665d00d0..1b37e4c26 100644 --- a/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_test.exs +++ b/test/pleroma/web/activity_pub/mrf/steal_emoji_policy_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.ActivityPub.MRF.StealEmojiPolicyTest do @@ -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)