diff options
| author | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-02-15 20:41:38 +0300 |
|---|---|---|
| committer | Ivan Tashkinov <ivantashkinov@gmail.com> | 2020-02-15 20:41:38 +0300 |
| commit | 269d592181bff8601f6545b85158ee1c222ff20d (patch) | |
| tree | d9801ca0073b742eb4a338e831394df09e4acb45 /test/object | |
| parent | b95dd5e217e7e1477b53deb9992b65f20b5649ac (diff) | |
| download | pleroma-269d592181bff8601f6545b85158ee1c222ff20d.tar.gz pleroma-269d592181bff8601f6545b85158ee1c222ff20d.zip | |
[#1505] Restricted max thread distance for fetching replies on incoming federation (in addition to reply-to depth restriction).
Diffstat (limited to 'test/object')
| -rw-r--r-- | test/object/fetcher_test.exs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/object/fetcher_test.exs b/test/object/fetcher_test.exs index 2aad7a588..3afd35648 100644 --- a/test/object/fetcher_test.exs +++ b/test/object/fetcher_test.exs @@ -26,6 +26,31 @@ defmodule Pleroma.Object.FetcherTest do :ok end + describe "max thread distance restriction" do + @ap_id "http://mastodon.example.org/@admin/99541947525187367" + + 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) + + 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) + + 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) + + assert {:ok, _} = Fetcher.fetch_object_from_id(@ap_id, depth: 10) + end + end + describe "actor origin containment" do test "it rejects objects with a bogus origin" do {:error, _} = Fetcher.fetch_object_from_id("https://info.pleroma.site/activity.json") |
