aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrinpatch <rinpatch@sdf.org>2019-12-16 01:03:13 +0300
committerrinpatch <rinpatch@sdf.org>2019-12-16 01:03:13 +0300
commit54029fe21271e7d4396699ee297f2910cd6fbbdc (patch)
tree70a32abacc2c2272302d7313961677dc81990488
parent137a3d220bba01e9cacd8007fa030c69830cc9aa (diff)
downloadpleroma-54029fe21271e7d4396699ee297f2910cd6fbbdc.tar.gz
tests: remove a useless sleep in rate limiter tests
It was used to check that authenticated and unauthenticated users have different limits. Instead of sleeping a super low limit for unauthenticated users was set, preventing them from doing 5 requests in the first place.
-rw-r--r--test/conversation/participation_test.exs2
-rw-r--r--test/plugs/rate_limiter_test.exs14
2 files changed, 3 insertions, 13 deletions
diff --git a/test/conversation/participation_test.exs b/test/conversation/participation_test.exs
index 88dc32198..ba81c0d4b 100644
--- a/test/conversation/participation_test.exs
+++ b/test/conversation/participation_test.exs
@@ -99,7 +99,7 @@ defmodule Pleroma.Conversation.ParticipationTest do
assert participation.user_id == user.id
assert participation.conversation_id == conversation.id
-
+
# Needed because updated_at is accurate down to a second
:timer.sleep(1000)
diff --git a/test/plugs/rate_limiter_test.exs b/test/plugs/rate_limiter_test.exs
index 49f63c424..78f1ea9e4 100644
--- a/test/plugs/rate_limiter_test.exs
+++ b/test/plugs/rate_limiter_test.exs
@@ -145,9 +145,9 @@ defmodule Pleroma.Plugs.RateLimiterTest do
test "can have limits seperate from unauthenticated connections" do
limiter_name = :test_authenticated
- scale = 1000
+ scale = 50
limit = 5
- Pleroma.Config.put([:rate_limit, limiter_name], [{1, 10}, {scale, limit}])
+ Pleroma.Config.put([:rate_limit, limiter_name], [{1000, 1}, {scale, limit}])
opts = RateLimiter.init(name: limiter_name)
@@ -164,16 +164,6 @@ defmodule Pleroma.Plugs.RateLimiterTest do
assert %{"error" => "Throttled"} = Phoenix.ConnTest.json_response(conn, :too_many_requests)
assert conn.halted
-
- Process.sleep(1550)
-
- conn = conn(:get, "/") |> assign(:user, user)
- conn = RateLimiter.call(conn, opts)
- assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, opts)
-
- refute conn.status == Plug.Conn.Status.code(:too_many_requests)
- refute conn.resp_body
- refute conn.halted
end
test "diffrerent users are counted independently" do