diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index 66638a4..4f2241c 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -29,11 +29,6 @@ class Rack::Attack self.safelists[name] = Safelist.new(name, block) end - def whitelist(name, &block) - warn "[DEPRECATION] 'Rack::Attack.whitelist' is deprecated. Please use 'safelist' instead." - safelist(name, &block) - end - def blocklist(name, &block) self.blocklists[name] = Blocklist.new(name, block) end @@ -50,11 +45,6 @@ class Rack::Attack @ip_safelists << Safelist.new(nil, ip_safelist_proc) end - def blacklist(name, &block) - warn "[DEPRECATION] 'Rack::Attack.blacklist' is deprecated. Please use 'blocklist' instead." - blocklist(name, &block) - end - def throttle(name, options, &block) self.throttles[name] = Throttle.new(name, options, block) end @@ -71,36 +61,16 @@ class Rack::Attack def tracks; @tracks ||= {}; end - def whitelists - warn "[DEPRECATION] 'Rack::Attack.whitelists' is deprecated. Please use 'safelists' instead." - safelists - end - - def blacklists - warn "[DEPRECATION] 'Rack::Attack.blacklists' is deprecated. Please use 'blocklists' instead." - blocklists - end - def safelisted?(request) ip_safelists.any? { |safelist| safelist.matched_by?(request) } || safelists.any? { |_name, safelist| safelist.matched_by?(request) } end - def whitelisted?(request) - warn "[DEPRECATION] 'Rack::Attack.whitelisted?' is deprecated. Please use 'safelisted?' instead." - safelisted?(request) - end - def blocklisted?(request) ip_blocklists.any? { |blocklist| blocklist.matched_by?(request) } || blocklists.any? { |_name, blocklist| blocklist.matched_by?(request) } end - def blacklisted?(request) - warn "[DEPRECATION] 'Rack::Attack.blacklisted?' is deprecated. Please use 'blocklisted?' instead." - blocklisted?(request) - end - def throttled?(request) throttles.any? do |_name, throttle| throttle.matched_by?(request) @@ -132,16 +102,6 @@ class Rack::Attack clear_configuration end - def blacklisted_response=(res) - warn "[DEPRECATION] 'Rack::Attack.blacklisted_response=' is deprecated. Please use 'blocklisted_response=' instead." - self.blocklisted_response = res - end - - def blacklisted_response - warn "[DEPRECATION] 'Rack::Attack.blacklisted_response' is deprecated. Please use 'blocklisted_response' instead." - blocklisted_response - end - private def ip_blocklists diff --git a/spec/rack_attack_spec.rb b/spec/rack_attack_spec.rb index 3869b71..c31b670 100644 --- a/spec/rack_attack_spec.rb +++ b/spec/rack_attack_spec.rb @@ -24,13 +24,6 @@ describe 'Rack::Attack' do Rack::Attack.blocklists.key?("ip #{@bad_ip}").must_equal true } - it('has a blacklist with a deprication warning') { - _, stderror = capture_io do - Rack::Attack.blacklists.key?("ip #{@bad_ip}").must_equal true - end - assert_match "[DEPRECATION] 'Rack::Attack.blacklists' is deprecated. Please use 'blocklists' instead.", stderror - } - describe "a bad request" do before { get '/', {}, 'REMOTE_ADDR' => @bad_ip } @@ -55,13 +48,6 @@ describe 'Rack::Attack' do it('has a safelist') { Rack::Attack.safelists.key?("good ua") } - it('has a whitelist with a deprication warning') { - _, stderror = capture_io do - Rack::Attack.whitelists.key?("good ua") - end - assert_match "[DEPRECATION] 'Rack::Attack.whitelists' is deprecated. Please use 'safelists' instead.", stderror - } - describe "with a request match both safelist & blocklist" do before { get '/', {}, 'REMOTE_ADDR' => @bad_ip, 'HTTP_USER_AGENT' => @good_ua } @@ -80,13 +66,6 @@ describe 'Rack::Attack' do it 'should exist' do Rack::Attack.blocklisted_response.must_respond_to :call end - - it 'should give a deprication warning for blacklisted_response' do - _, stderror = capture_io do - Rack::Attack.blacklisted_response - end - assert_match "[DEPRECATION] 'Rack::Attack.blacklisted_response' is deprecated. Please use 'blocklisted_response' instead.", stderror - end end describe '#throttled_response' do