mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-04-27 15:07:41 +00:00
doc: add Testing section to the README
This commit is contained in:
parent
aa071aa5df
commit
35e4983400
1 changed files with 11 additions and 0 deletions
11
README.md
11
README.md
|
|
@ -37,6 +37,7 @@ See the [Backing & Hacking blog post](https://www.kickstarter.com/backing-and-ha
|
||||||
- [Customizing responses](#customizing-responses)
|
- [Customizing responses](#customizing-responses)
|
||||||
- [RateLimit headers for well-behaved clients](#ratelimit-headers-for-well-behaved-clients)
|
- [RateLimit headers for well-behaved clients](#ratelimit-headers-for-well-behaved-clients)
|
||||||
- [Logging & Instrumentation](#logging--instrumentation)
|
- [Logging & Instrumentation](#logging--instrumentation)
|
||||||
|
- [Testing](#testing)
|
||||||
- [How it works](#how-it-works)
|
- [How it works](#how-it-works)
|
||||||
- [About Tracks](#about-tracks)
|
- [About Tracks](#about-tracks)
|
||||||
- [Testing](#testing)
|
- [Testing](#testing)
|
||||||
|
|
@ -398,6 +399,16 @@ ActiveSupport::Notifications.subscribe(/rack_attack/) do |name, start, finish, r
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
### Disabling
|
||||||
|
|
||||||
|
`Rack::Attack.enabled = false` can be used to either completely disable Rack::Attack in your tests, or to disable/enable for specific test cases only.
|
||||||
|
|
||||||
|
### Test case isolation
|
||||||
|
|
||||||
|
`Rack::Attack.reset!` can be used in your test suite to clear any Rack::Attack state between different test cases.
|
||||||
|
|
||||||
## How it works
|
## How it works
|
||||||
|
|
||||||
The Rack::Attack middleware compares each request against *safelists*, *blocklists*, *throttles*, and *tracks* that you define. There are none by default.
|
The Rack::Attack middleware compares each request against *safelists*, *blocklists*, *throttles*, and *tracks* that you define. There are none by default.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue