forked from AkkomaGang/akkoma
Merge branch 'fix-warnings-in-tests' into 'develop'
Warnings fix See merge request pleroma/pleroma!2303
This commit is contained in:
commit
ac5c2b66b9
1 changed files with 14 additions and 14 deletions
|
@ -51,7 +51,7 @@ test "it restricts based on config values" do
|
||||||
Config.put([:rate_limit, limiter_name], {scale, limit})
|
Config.put([:rate_limit, limiter_name], {scale, limit})
|
||||||
|
|
||||||
plug_opts = RateLimiter.init(name: limiter_name)
|
plug_opts = RateLimiter.init(name: limiter_name)
|
||||||
conn = conn(:get, "/")
|
conn = build_conn(:get, "/")
|
||||||
|
|
||||||
for i <- 1..5 do
|
for i <- 1..5 do
|
||||||
conn = RateLimiter.call(conn, plug_opts)
|
conn = RateLimiter.call(conn, plug_opts)
|
||||||
|
@ -65,7 +65,7 @@ test "it restricts based on config values" do
|
||||||
|
|
||||||
Process.sleep(50)
|
Process.sleep(50)
|
||||||
|
|
||||||
conn = conn(:get, "/")
|
conn = build_conn(:get, "/")
|
||||||
|
|
||||||
conn = RateLimiter.call(conn, plug_opts)
|
conn = RateLimiter.call(conn, plug_opts)
|
||||||
assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, plug_opts)
|
assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, plug_opts)
|
||||||
|
@ -85,7 +85,7 @@ test "`bucket_name` option overrides default bucket name" do
|
||||||
base_bucket_name = "#{limiter_name}:group1"
|
base_bucket_name = "#{limiter_name}:group1"
|
||||||
plug_opts = RateLimiter.init(name: limiter_name, bucket_name: base_bucket_name)
|
plug_opts = RateLimiter.init(name: limiter_name, bucket_name: base_bucket_name)
|
||||||
|
|
||||||
conn = conn(:get, "/")
|
conn = build_conn(:get, "/")
|
||||||
|
|
||||||
RateLimiter.call(conn, plug_opts)
|
RateLimiter.call(conn, plug_opts)
|
||||||
assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, plug_opts)
|
assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, plug_opts)
|
||||||
|
@ -99,9 +99,9 @@ test "`params` option allows different queries to be tracked independently" do
|
||||||
|
|
||||||
plug_opts = RateLimiter.init(name: limiter_name, params: ["id"])
|
plug_opts = RateLimiter.init(name: limiter_name, params: ["id"])
|
||||||
|
|
||||||
conn = conn(:get, "/?id=1")
|
conn = build_conn(:get, "/?id=1")
|
||||||
conn = Plug.Conn.fetch_query_params(conn)
|
conn = Plug.Conn.fetch_query_params(conn)
|
||||||
conn_2 = conn(:get, "/?id=2")
|
conn_2 = build_conn(:get, "/?id=2")
|
||||||
|
|
||||||
RateLimiter.call(conn, plug_opts)
|
RateLimiter.call(conn, plug_opts)
|
||||||
assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, plug_opts)
|
assert {1, 4} = RateLimiter.inspect_bucket(conn, limiter_name, plug_opts)
|
||||||
|
@ -120,9 +120,9 @@ test "it supports combination of options modifying bucket name" do
|
||||||
|
|
||||||
id = "100"
|
id = "100"
|
||||||
|
|
||||||
conn = conn(:get, "/?id=#{id}")
|
conn = build_conn(:get, "/?id=#{id}")
|
||||||
conn = Plug.Conn.fetch_query_params(conn)
|
conn = Plug.Conn.fetch_query_params(conn)
|
||||||
conn_2 = conn(:get, "/?id=#{101}")
|
conn_2 = build_conn(:get, "/?id=#{101}")
|
||||||
|
|
||||||
RateLimiter.call(conn, plug_opts)
|
RateLimiter.call(conn, plug_opts)
|
||||||
assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, plug_opts)
|
assert {1, 4} = RateLimiter.inspect_bucket(conn, base_bucket_name, plug_opts)
|
||||||
|
@ -138,8 +138,8 @@ test "are restricted based on remote IP" do
|
||||||
|
|
||||||
plug_opts = RateLimiter.init(name: limiter_name)
|
plug_opts = RateLimiter.init(name: limiter_name)
|
||||||
|
|
||||||
conn = %{conn(:get, "/") | remote_ip: {127, 0, 0, 2}}
|
conn = %{build_conn(:get, "/") | remote_ip: {127, 0, 0, 2}}
|
||||||
conn_2 = %{conn(:get, "/") | remote_ip: {127, 0, 0, 3}}
|
conn_2 = %{build_conn(:get, "/") | remote_ip: {127, 0, 0, 3}}
|
||||||
|
|
||||||
for i <- 1..5 do
|
for i <- 1..5 do
|
||||||
conn = RateLimiter.call(conn, plug_opts)
|
conn = RateLimiter.call(conn, plug_opts)
|
||||||
|
@ -179,7 +179,7 @@ test "can have limits separate from unauthenticated connections" do
|
||||||
plug_opts = RateLimiter.init(name: limiter_name)
|
plug_opts = RateLimiter.init(name: limiter_name)
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
conn = conn(:get, "/") |> assign(:user, user)
|
conn = build_conn(:get, "/") |> assign(:user, user)
|
||||||
|
|
||||||
for i <- 1..5 do
|
for i <- 1..5 do
|
||||||
conn = RateLimiter.call(conn, plug_opts)
|
conn = RateLimiter.call(conn, plug_opts)
|
||||||
|
@ -201,10 +201,10 @@ test "different users are counted independently" do
|
||||||
plug_opts = RateLimiter.init(name: limiter_name)
|
plug_opts = RateLimiter.init(name: limiter_name)
|
||||||
|
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
conn = conn(:get, "/") |> assign(:user, user)
|
conn = build_conn(:get, "/") |> assign(:user, user)
|
||||||
|
|
||||||
user_2 = insert(:user)
|
user_2 = insert(:user)
|
||||||
conn_2 = conn(:get, "/") |> assign(:user, user_2)
|
conn_2 = build_conn(:get, "/") |> assign(:user, user_2)
|
||||||
|
|
||||||
for i <- 1..5 do
|
for i <- 1..5 do
|
||||||
conn = RateLimiter.call(conn, plug_opts)
|
conn = RateLimiter.call(conn, plug_opts)
|
||||||
|
@ -230,8 +230,8 @@ test "doesn't crash due to a race condition when multiple requests are made at t
|
||||||
|
|
||||||
opts = RateLimiter.init(name: limiter_name)
|
opts = RateLimiter.init(name: limiter_name)
|
||||||
|
|
||||||
conn = conn(:get, "/")
|
conn = build_conn(:get, "/")
|
||||||
conn_2 = conn(:get, "/")
|
conn_2 = build_conn(:get, "/")
|
||||||
|
|
||||||
%Task{pid: pid1} =
|
%Task{pid: pid1} =
|
||||||
task1 =
|
task1 =
|
||||||
|
|
Loading…
Reference in a new issue