aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorlain <lain@soykaf.club>2018-12-26 12:39:35 +0100
committerlain <lain@soykaf.club>2018-12-26 12:39:35 +0100
commit5811e65e67591b06238de66470c03744e0d83e2d (patch)
tree2fa0c03884b8fb2437f0721a7283dd3f75ed5c80 /test
parent922abcda61298a7bca48894cb9a51a52fdeab1ed (diff)
downloadpleroma-5811e65e67591b06238de66470c03744e0d83e2d.tar.gz
Add some hard limits on inserted activities.
Diffstat (limited to 'test')
-rw-r--r--test/web/activity_pub/activity_pub_test.exs18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs
index 4f6b7f058..f7c7c6242 100644
--- a/test/web/activity_pub/activity_pub_test.exs
+++ b/test/web/activity_pub/activity_pub_test.exs
@@ -31,6 +31,24 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do
end
describe "insertion" do
+ test "drops activities beyond a certain limit" do
+ limit = Pleroma.Config.get([:instance, :remote_limit])
+
+ random_text =
+ :crypto.strong_rand_bytes(limit + 1)
+ |> Base.encode64()
+ |> binary_part(0, limit + 1)
+
+ data = %{
+ "ok" => true,
+ "object" => %{
+ "content" => random_text
+ }
+ }
+
+ assert {:error, {:remote_limit_error, _}} = ActivityPub.insert(data)
+ end
+
test "returns the activity if one with the same id is already in" do
activity = insert(:note_activity)
{:ok, new_activity} = ActivityPub.insert(activity.data)