fix edge case, if maxretry is 1, let them get 1 request in

This commit is contained in:
Jordan Moncharmont 2013-09-27 17:35:01 -07:00
parent ef59c5182a
commit 273e045f10
2 changed files with 4 additions and 5 deletions

View file

@ -13,10 +13,9 @@ module Rack
count = cache.count("#{key_prefix}:count:#{discriminator}", findtime)
if count >= maxretry
ban!(discriminator, bantime)
true
else
false
end
# we may not block them this time, but they're banned for next time
false
end
end
end

View file

@ -45,8 +45,8 @@ describe 'Rack::Attack.Allow2Ban' do
get '/?foo=OMGHAX', {}, 'REMOTE_ADDR' => '1.2.3.4'
end
it 'fails' do
last_response.status.must_equal 401
it 'succeeds' do
last_response.status.must_equal 200
end
it 'increases fail count' do