mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Acceptance test that tracking throttles doesn't actually throttle requests
This commit is contained in:
parent
066434973f
commit
564cbedb36
1 changed files with 9 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ require_relative "../spec_helper"
|
|||
require "timecop"
|
||||
|
||||
describe "#track with throttle-ish options" do
|
||||
it "notifies when throttle goes over the limit" do
|
||||
it "notifies when throttle goes over the limit without actually throttling requests" do
|
||||
Rack::Attack.cache.store = ActiveSupport::Cache::MemoryStore.new
|
||||
|
||||
Rack::Attack.track("by ip", limit: 1, period: 60) do |request|
|
||||
|
|
@ -22,16 +22,22 @@ describe "#track with throttle-ish options" do
|
|||
assert_nil notification_matched
|
||||
assert_nil notification_type
|
||||
|
||||
assert_equal 200, last_response.status
|
||||
|
||||
get "/", {}, "REMOTE_ADDR" => "5.6.7.8"
|
||||
|
||||
assert_nil notification_matched
|
||||
assert_nil notification_type
|
||||
|
||||
assert_equal 200, last_response.status
|
||||
|
||||
get "/", {}, "REMOTE_ADDR" => "1.2.3.4"
|
||||
|
||||
assert_equal "by ip", notification_matched
|
||||
assert_equal :track, notification_type
|
||||
|
||||
assert_equal 200, last_response.status
|
||||
|
||||
Timecop.travel(60) do
|
||||
notification_matched = nil
|
||||
notification_type = nil
|
||||
|
|
@ -40,6 +46,8 @@ describe "#track with throttle-ish options" do
|
|||
|
||||
assert_nil notification_matched
|
||||
assert_nil notification_type
|
||||
|
||||
assert_equal 200, last_response.status
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue