summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2020-09-16 13:37:04 +0000
committerrinpatch <rinpatch@sdf.org>2020-09-16 13:37:04 +0000
commiteca8d267846afc802f9a5ceed036482a9c90b4e2 (patch)
treee2cb3726e023ded784a45bba061108135e4a2855 /test
parentadbd0032fab0f2515689fd2ab6629fb8cd05b09d (diff)
parentf1f44069ae525fd21127e5ceccc61016c12f4427 (diff)
downloadpleroma-eca8d267846afc802f9a5ceed036482a9c90b4e2.tar.gz
pleroma-eca8d267846afc802f9a5ceed036482a9c90b4e2.zip
Merge branch 'chores/mrf-loglevel' into 'develop'
Fetcher: Correctly return MRF reject reason See merge request pleroma/pleroma!2990
Diffstat (limited to 'test')
-rw-r--r--test/object/fetcher_test.exs25
1 files changed, 19 insertions, 6 deletions
diff --git a/test/object/fetcher_test.exs b/test/object/fetcher_test.exs
index 16cfa7f5c..3173ee31c 100644
--- a/test/object/fetcher_test.exs
+++ b/test/object/fetcher_test.exs
@@ -6,10 +6,13 @@ defmodule Pleroma.Object.FetcherTest do
use Pleroma.DataCase
alias Pleroma.Activity
+ alias Pleroma.Config
alias Pleroma.Object
alias Pleroma.Object.Fetcher
- import Tesla.Mock
+
+ import ExUnit.CaptureLog
import Mock
+ import Tesla.Mock
setup do
mock(fn
@@ -71,20 +74,20 @@ defmodule Pleroma.Object.FetcherTest do
setup do: clear_config([:instance, :federation_incoming_replies_max_depth])
test "it returns thread depth exceeded error if thread depth is exceeded" do
- Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
+ Config.put([:instance, :federation_incoming_replies_max_depth], 0)
assert {:error, "Max thread distance exceeded."} =
Fetcher.fetch_object_from_id(@ap_id, depth: 1)
end
test "it fetches object if max thread depth is restricted to 0 and depth is not specified" do
- Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 0)
+ Config.put([:instance, :federation_incoming_replies_max_depth], 0)
assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id)
end
test "it fetches object if requested depth does not exceed max thread depth" do
- Pleroma.Config.put([:instance, :federation_incoming_replies_max_depth], 10)
+ Config.put([:instance, :federation_incoming_replies_max_depth], 10)
assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id, depth: 10)
end
@@ -120,6 +123,16 @@ defmodule Pleroma.Object.FetcherTest do
assert object == object_again
end
+
+ test "Return MRF reason when fetched status is rejected by one" do
+ clear_config([:mrf_keyword, :reject], ["yeah"])
+ clear_config([:mrf, :policies], [Pleroma.Web.ActivityPub.MRF.KeywordPolicy])
+
+ assert {:reject, "[KeywordPolicy] Matches with rejected keyword"} ==
+ Fetcher.fetch_object_from_id(
+ "http://mastodon.example.org/@admin/99541947525187367"
+ )
+ end
end
describe "implementation quirks" do
@@ -212,7 +225,7 @@ defmodule Pleroma.Object.FetcherTest do
Pleroma.Signature,
[:passthrough],
[] do
- Pleroma.Config.put([:activitypub, :sign_object_fetches], true)
+ Config.put([:activitypub, :sign_object_fetches], true)
Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
@@ -223,7 +236,7 @@ defmodule Pleroma.Object.FetcherTest do
Pleroma.Signature,
[:passthrough],
[] do
- Pleroma.Config.put([:activitypub, :sign_object_fetches], false)
+ Config.put([:activitypub, :sign_object_fetches], false)
Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")