From aaeff6d0ae7d06a97c3f438321dea3edbca55acd Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Sat, 29 Jan 2022 15:09:54 -0300 Subject: [PATCH] feat: deprecate throttled_response and blocklisted_response --- lib/rack/attack/configuration.rb | 10 ++++------ spec/acceptance/customizing_blocked_response_spec.rb | 6 ++++-- spec/acceptance/customizing_throttled_response_spec.rb | 6 ++++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/rack/attack/configuration.rb b/lib/rack/attack/configuration.rb index 67bcc611..ba353ab4 100644 --- a/lib/rack/attack/configuration.rb +++ b/lib/rack/attack/configuration.rb @@ -25,16 +25,14 @@ class Configuration attr_reader :blocklisted_response, :throttled_response # Keeping these for backwards compatibility def blocklisted_response=(responder) - # TODO: uncomment in 7.0 - # warn "[DEPRECATION] Rack::Attack.blocklisted_response is deprecated. "\ - # "Please use Rack::Attack.blocklisted_responder instead." + warn "[DEPRECATION] Rack::Attack.blocklisted_response is deprecated. "\ + "Please use Rack::Attack.blocklisted_responder instead." @blocklisted_response = responder end def throttled_response=(responder) - # TODO: uncomment in 7.0 - # warn "[DEPRECATION] Rack::Attack.throttled_response is deprecated. "\ - # "Please use Rack::Attack.throttled_responder instead" + warn "[DEPRECATION] Rack::Attack.throttled_response is deprecated. "\ + "Please use Rack::Attack.throttled_responder instead" @throttled_response = responder end diff --git a/spec/acceptance/customizing_blocked_response_spec.rb b/spec/acceptance/customizing_blocked_response_spec.rb index 86fcd02a..1ca127cc 100644 --- a/spec/acceptance/customizing_blocked_response_spec.rb +++ b/spec/acceptance/customizing_blocked_response_spec.rb @@ -46,8 +46,10 @@ assert_equal 403, last_response.status - Rack::Attack.blocklisted_response = lambda do |_env| - [503, {}, ["Blocked"]] + silence_warnings do + Rack::Attack.blocklisted_response = lambda do |_env| + [503, {}, ["Blocked"]] + end end get "/", {}, "REMOTE_ADDR" => "1.2.3.4" diff --git a/spec/acceptance/customizing_throttled_response_spec.rb b/spec/acceptance/customizing_throttled_response_spec.rb index 39a39502..0990975e 100644 --- a/spec/acceptance/customizing_throttled_response_spec.rb +++ b/spec/acceptance/customizing_throttled_response_spec.rb @@ -68,8 +68,10 @@ assert_equal 429, last_response.status - Rack::Attack.throttled_response = lambda do |_req| - [503, {}, ["Throttled"]] + silence_warnings do + Rack::Attack.throttled_response = lambda do |_req| + [503, {}, ["Throttled"]] + end end get "/", {}, "REMOTE_ADDR" => "1.2.3.4"