diff options
| author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-02-17 14:07:04 +0300 |
|---|---|---|
| committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2019-02-17 14:07:04 +0300 |
| commit | bc4f77b10bb4360ac00d1999b1d08fa55e1fa547 (patch) | |
| tree | 8c87c2cefd1e325a64a19c04d7d7d70ffd8cc485 /test/web/activity_pub/mrf/hellthread_policy_test.exs | |
| parent | dcf24a3233bb50689d26f9d7833f98158730ce35 (diff) | |
| parent | 3b141194715e362d65482672d00b10991d102fa2 (diff) | |
| download | pleroma-bc4f77b10bb4360ac00d1999b1d08fa55e1fa547.tar.gz pleroma-bc4f77b10bb4360ac00d1999b1d08fa55e1fa547.zip | |
[#468] Merged `upstream/develop`, resolved conflicts.
Diffstat (limited to 'test/web/activity_pub/mrf/hellthread_policy_test.exs')
| -rw-r--r-- | test/web/activity_pub/mrf/hellthread_policy_test.exs | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/web/activity_pub/mrf/hellthread_policy_test.exs b/test/web/activity_pub/mrf/hellthread_policy_test.exs new file mode 100644 index 000000000..ebf9997cd --- /dev/null +++ b/test/web/activity_pub/mrf/hellthread_policy_test.exs @@ -0,0 +1,50 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2019 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Web.ActivityPub.MRF.HellthreadPolicyTest do + use Pleroma.DataCase + import Pleroma.Factory + + import Pleroma.Web.ActivityPub.MRF.HellthreadPolicy + + describe "hellthread filter tests" do + setup do + user = insert(:user) + + message = %{ + "actor" => user.ap_id, + "cc" => [user.follower_address], + "type" => "Create", + "to" => [ + "https://www.w3.org/ns/activitystreams#Public", + "https://instace.tld/users/user1", + "https://instace.tld/users/user2", + "https://instace.tld/users/user3" + ] + } + + [user: user, message: message] + end + + test "reject test", %{message: message} do + Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 2}) + + {:reject, nil} = filter(message) + end + + test "delist test", %{user: user, message: message} do + Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 2, reject_threshold: 0}) + + {:ok, message} = filter(message) + assert user.follower_address in message["to"] + assert "https://www.w3.org/ns/activitystreams#Public" in message["cc"] + end + + test "excludes follower collection and public URI from threshold count", %{message: message} do + Pleroma.Config.put([:mrf_hellthread], %{delist_threshold: 0, reject_threshold: 3}) + + {:ok, _} = filter(message) + end + end +end |
