aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAriadne Conill <ariadne@dereferenced.org>2019-07-17 22:58:52 +0000
committerAriadne Conill <ariadne@dereferenced.org>2019-07-17 23:06:16 +0000
commit1345e0c2bf51c7eb8add41a25683e121c83c1ff8 (patch)
treed1ab666862e67f4ccac11d36e159748d14a256d4 /test
parent399acd4c42ae3f1c072c097ff9fabc9761c3d3c1 (diff)
downloadpleroma-1345e0c2bf51c7eb8add41a25683e121c83c1ff8.tar.gz
tests: add tests for signed object fetches
Diffstat (limited to 'test')
-rw-r--r--test/object/fetcher_test.exs30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/object/fetcher_test.exs b/test/object/fetcher_test.exs
index 56a9d775f..482252cff 100644
--- a/test/object/fetcher_test.exs
+++ b/test/object/fetcher_test.exs
@@ -150,4 +150,34 @@ defmodule Pleroma.Object.FetcherTest do
assert object.id != object_two.id
end
end
+
+ describe "signed fetches" do
+ test_with_mock "it signs fetches when configured to do so",
+ Pleroma.Signature,
+ [:passthrough],
+ [] do
+ option = Pleroma.Config.get([:activitypub, :sign_object_fetches])
+ Pleroma.Config.put([:activitypub, :sign_object_fetches], true)
+
+ Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
+
+ assert called(Pleroma.Signature.sign(:_, :_))
+
+ Pleroma.Config.put([:activitypub, :sign_object_fetches], option)
+ end
+
+ test_with_mock "it doesn't sign fetches when not configured to do so",
+ Pleroma.Signature,
+ [:passthrough],
+ [] do
+ option = Pleroma.Config.get([:activitypub, :sign_object_fetches])
+ Pleroma.Config.put([:activitypub, :sign_object_fetches], false)
+
+ Fetcher.fetch_object_from_id("http://mastodon.example.org/@admin/99541947525187367")
+
+ refute called(Pleroma.Signature.sign(:_, :_))
+
+ Pleroma.Config.put([:activitypub, :sign_object_fetches], option)
+ end
+ end
end