diff options
| author | lain <lain@soykaf.club> | 2020-08-03 14:12:32 +0200 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2020-08-03 14:12:32 +0200 | 
| commit | 10c792110e6ea8ed21f739ef8f4f0eff4659ebf9 (patch) | |
| tree | 60338148a0cc820070a5f9b27759c8649f41a72e /test/web | |
| parent | ac0a8dfdd46b1823cace7fb798d669e8ca7b5dac (diff) | |
| download | pleroma-10c792110e6ea8ed21f739ef8f4f0eff4659ebf9.tar.gz pleroma-10c792110e6ea8ed21f739ef8f4f0eff4659ebf9.zip | |
MRF Object Age Policy: Don't break on messages without cc/to
Diffstat (limited to 'test/web')
| -rw-r--r-- | test/web/activity_pub/mrf/object_age_policy_test.exs | 42 | 
1 files changed, 42 insertions, 0 deletions
| diff --git a/test/web/activity_pub/mrf/object_age_policy_test.exs b/test/web/activity_pub/mrf/object_age_policy_test.exs index b0fb753bd..cf6acc9a2 100644 --- a/test/web/activity_pub/mrf/object_age_policy_test.exs +++ b/test/web/activity_pub/mrf/object_age_policy_test.exs @@ -38,6 +38,17 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do    end    describe "with reject action" do +    test "works with objects with empty to or cc fields" do +      Config.put([:mrf_object_age, :actions], [:reject]) + +      data = +        get_old_message() +        |> Map.put("cc", nil) +        |> Map.put("to", nil) + +      assert match?({:reject, _}, ObjectAgePolicy.filter(data)) +    end +      test "it rejects an old post" do        Config.put([:mrf_object_age, :actions], [:reject]) @@ -56,6 +67,21 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do    end    describe "with delist action" do +    test "works with objects with empty to or cc fields" do +      Config.put([:mrf_object_age, :actions], [:delist]) + +      data = +        get_old_message() +        |> Map.put("cc", nil) +        |> Map.put("to", nil) + +      {:ok, _u} = User.get_or_fetch_by_ap_id(data["actor"]) + +      {:ok, data} = ObjectAgePolicy.filter(data) + +      assert Visibility.get_visibility(%{data: data}) == "unlisted" +    end +      test "it delists an old post" do        Config.put([:mrf_object_age, :actions], [:delist]) @@ -80,6 +106,22 @@ defmodule Pleroma.Web.ActivityPub.MRF.ObjectAgePolicyTest do    end    describe "with strip_followers action" do +    test "works with objects with empty to or cc fields" do +      Config.put([:mrf_object_age, :actions], [:strip_followers]) + +      data = +        get_old_message() +        |> Map.put("cc", nil) +        |> Map.put("to", nil) + +      {:ok, user} = User.get_or_fetch_by_ap_id(data["actor"]) + +      {:ok, data} = ObjectAgePolicy.filter(data) + +      refute user.follower_address in data["to"] +      refute user.follower_address in data["cc"] +    end +      test "it strips followers collections from an old post" do        Config.put([:mrf_object_age, :actions], [:strip_followers]) | 
