From 427fdfabbc4b6283af14b6916dec4d2d4074e9e4 Mon Sep 17 00:00:00 2001 From: Alex Martens Date: Mon, 24 Jun 2024 10:46:01 -0700 Subject: [PATCH] Add tracks attr_reader to Configuration (#664) --- lib/rack/attack/configuration.rb | 2 +- spec/configuration_spec.rb | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 spec/configuration_spec.rb diff --git a/lib/rack/attack/configuration.rb b/lib/rack/attack/configuration.rb index a4bdc987..81f81915 100644 --- a/lib/rack/attack/configuration.rb +++ b/lib/rack/attack/configuration.rb @@ -19,7 +19,7 @@ class Configuration end end - attr_reader :safelists, :blocklists, :throttles, :anonymous_blocklists, :anonymous_safelists + attr_reader :safelists, :blocklists, :throttles, :tracks, :anonymous_blocklists, :anonymous_safelists attr_accessor :blocklisted_responder, :throttled_responder, :throttled_response_retry_after_header attr_reader :blocklisted_response, :throttled_response # Keeping these for backwards compatibility diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb new file mode 100644 index 00000000..78a4b34d --- /dev/null +++ b/spec/configuration_spec.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +require_relative "spec_helper" + +describe Rack::Attack::Configuration do + subject { Rack::Attack::Configuration.new } + + describe 'attributes' do + it 'exposes the safelists attribute' do + _(subject.safelists).must_equal({}) + end + + it 'exposes the blocklists attribute' do + _(subject.blocklists).must_equal({}) + end + + it 'exposes the throttles attribute' do + _(subject.throttles).must_equal({}) + end + + it 'exposes the tracks attribute' do + _(subject.tracks).must_equal({}) + end + + it 'exposes the anonymous_blocklists attribute' do + _(subject.anonymous_blocklists).must_equal([]) + end + + it 'exposes the anonymous_safelists attribute' do + _(subject.anonymous_safelists).must_equal([]) + end + end +end