diff options
| author | William Pitcock <nenolod@dereferenced.org> | 2019-05-22 05:08:37 +0000 | 
|---|---|---|
| committer | William Pitcock <nenolod@dereferenced.org> | 2019-05-22 18:53:12 +0000 | 
| commit | 8086c7aed6cdc3b2ac1c09c6c40344e47be08ed9 (patch) | |
| tree | e9b5c877fdb3ba993a8bac64c24964b2adec25d4 /test/web/activity_pub | |
| parent | baf72d6c580e5c05ef5fea8a57c57150a5d38589 (diff) | |
| download | pleroma-8086c7aed6cdc3b2ac1c09c6c40344e47be08ed9.tar.gz pleroma-8086c7aed6cdc3b2ac1c09c6c40344e47be08ed9.zip | |
tests: add tests for banner and avatar removal
Diffstat (limited to 'test/web/activity_pub')
| -rw-r--r-- | test/web/activity_pub/mrf/simple_policy_test.exs | 73 | 
1 files changed, 72 insertions, 1 deletions
| diff --git a/test/web/activity_pub/mrf/simple_policy_test.exs b/test/web/activity_pub/mrf/simple_policy_test.exs index 74af7dcde..3d1f26e60 100644 --- a/test/web/activity_pub/mrf/simple_policy_test.exs +++ b/test/web/activity_pub/mrf/simple_policy_test.exs @@ -17,7 +17,9 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do        federated_timeline_removal: [],        report_removal: [],        reject: [], -      accept: [] +      accept: [], +      avatar_removal: [], +      banner_removal: []      )      on_exit(fn -> @@ -206,6 +208,60 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do      end    end +  describe "when :avatar_removal" do +    test "is empty" do +      Config.put([:mrf_simple, :avatar_removal], []) + +      remote_user = build_remote_user() + +      assert SimplePolicy.filter(remote_user) == {:ok, remote_user} +    end + +    test "is not empty but it doesn't have a matching host" do +      Config.put([:mrf_simple, :avatar_removal], ["non.matching.remote"]) + +      remote_user = build_remote_user() + +      assert SimplePolicy.filter(remote_user) == {:ok, remote_user} +    end + +    test "has a matching host" do +      Config.put([:mrf_simple, :avatar_removal], ["remote.instance"]) + +      remote_user = build_remote_user() +      {:ok, filtered} = SimplePolicy.filter(remote_user) + +      refute filtered["icon"] +    end +  end + +  describe "when :banner_removal" do +    test "is empty" do +      Config.put([:mrf_simple, :banner_removal], []) + +      remote_user = build_remote_user() + +      assert SimplePolicy.filter(remote_user) == {:ok, remote_user} +    end + +    test "is not empty but it doesn't have a matching host" do +      Config.put([:mrf_simple, :banner_removal], ["non.matching.remote"]) + +      remote_user = build_remote_user() + +      assert SimplePolicy.filter(remote_user) == {:ok, remote_user} +    end + +    test "has a matching host" do +      Config.put([:mrf_simple, :banner_removal], ["remote.instance"]) + +      remote_user = build_remote_user() +      {:ok, filtered} = SimplePolicy.filter(remote_user) + +      refute filtered["image"] +    end +  end +    defp build_local_message do      %{        "actor" => "#{Pleroma.Web.base_url()}/users/alice", @@ -217,4 +273,19 @@ defmodule Pleroma.Web.ActivityPub.MRF.SimplePolicyTest do    defp build_remote_message do      %{"actor" => "https://remote.instance/users/bob"}    end + +  defp build_remote_user do +    %{ +      "id" => "https://remote.instance/users/bob", +      "icon" => %{ +        "url" => "http://example.com/image.jpg", +        "type" => "Image" +      }, +      "image" => %{ +        "url" => "http://example.com/image.jpg", +        "type" => "Image" +      }, +      "type" => "Person" +    } +  end  end | 
