1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.ActivityPub.MRF.StealEmojiPolicyTest do
9 alias Pleroma.Web.ActivityPub.MRF.StealEmojiPolicy
12 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
17 emoji_path = Path.join(Config.get([:instance, :static_dir]), "emoji/stolen")
18 File.rm_rf!(emoji_path)
19 File.mkdir!(emoji_path)
21 Pleroma.Emoji.reload()
24 File.rm_rf!(emoji_path)
30 test "does nothing by default" do
31 installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
32 refute "firedfox" in installed_emoji
37 "emoji" => [{"firedfox", "https://example.org/emoji/firedfox.png"}],
38 "actor" => "https://example.org/users/admin"
42 assert {:ok, message} == StealEmojiPolicy.filter(message)
44 installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
45 refute "firedfox" in installed_emoji
48 test "Steals emoji on unknown shortcode from allowed remote host" do
49 installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
50 refute "firedfox" in installed_emoji
55 "emoji" => [{"firedfox", "https://example.org/emoji/firedfox.png"}],
56 "actor" => "https://example.org/users/admin"
60 clear_config([:mrf_steal_emoji, :hosts], ["example.org"])
61 clear_config([:mrf_steal_emoji, :size_limit], 284_468)
63 assert {:ok, message} == StealEmojiPolicy.filter(message)
65 installed_emoji = Pleroma.Emoji.get_all() |> Enum.map(fn {k, _} -> k end)
66 assert "firedfox" in installed_emoji