Skip to content
This repository has been archived by the owner on Jul 15, 2019. It is now read-only.

Commit

Permalink
Merge pull request #139 from WeTransfer/revert-disabling-throttoling
Browse files Browse the repository at this point in the history
Enable a rate limiter
  • Loading branch information
dsnipe authored Sep 21, 2017
2 parents 52e5ec9 + 84da6c0 commit 7c30bdb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/xperiments/web/controllers/assigner_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule Xperiments.Web.AssignerController do
use Xperiments.Web, :controller
alias Xperiments.{Repo, Experiment}

# plug Xperiments.Plug.RateLimit, max_requests: 5, interval_seconds: 60
plug Xperiments.Plug.RateLimit, max_requests: 5, interval_seconds: 60
plug :auth_request when action in [:example]

def experiments(conn, params) do
Expand Down
20 changes: 10 additions & 10 deletions test/controllers/assigner_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,16 @@ defmodule Xperiments.AssignerControllerTest do
assert db_exp.statistics.variants_impression == %{hd(context.exp.variants).id => 4}
end

# test "requests are throttled", context do
# for _i <- 0..4 do
# post(context.conn, "#{@api_path}/experiments/events", %{event: "impression", payload: context.call_payload})
# |> json_response(200)
# end
# body =
# post(context.conn, "#{@api_path}/experiments/events", %{event: "impression", payload: context.call_payload})
# |> json_response(403)
# assert body == %{"error" => "Rate limit exceeded"}
# end
test "requests are throttled", context do
for _i <- 0..4 do
post(context.conn, "#{@api_path}/experiments/events", %{event: "impression", payload: context.call_payload})
|> json_response(200)
end
body =
post(context.conn, "#{@api_path}/experiments/events", %{event: "impression", payload: context.call_payload})
|> json_response(403)
assert body == %{"error" => "Rate limit exceeded"}
end
end

describe "Rules/Segments logic" do
Expand Down

0 comments on commit 7c30bdb

Please sign in to comment.