-
Notifications
You must be signed in to change notification settings - Fork 337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resetting throttle count between tests #249
Comments
I'm doing this, it seems to work... Rack::Attack.throttles.each do |k, throttle|
Rack::Attack.cache.reset_count("#{k}:#{key}", throttle.period)
end |
Hi Declan, Great question. I think this is something we should add explicit support for, so users don't need to hack the cache store in order to achieve test case isolation in their app tests. It appears to me that |
For the record,
Issue with this goal is the following #301 |
We should consider adding a config.before do
Rack::Attack.reset!
end when using RSpec. |
|
Just wondering, what is the best way to reset the rack attack counters between "it" blocks in a spec, so that throttling can be tested independently in different "it" blocks.
I presume one would use an around block like this...
Then perhaps...
FYI, using ActiveSupport::Cache::MemoryStore as the backing store. Is a sleep required or is this synchronous?
Either way, it doesn't seem to be working quite right for me as I don't always get the expected number of 200's before I get a 429.
The text was updated successfully, but these errors were encountered: