diff options
Diffstat (limited to 'spec/lib/gitlab/auth/ip_rate_limiter_spec.rb')
-rw-r--r-- | spec/lib/gitlab/auth/ip_rate_limiter_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb b/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb index f23fdd3fbcb..3d9be4c3489 100644 --- a/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb +++ b/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb @@ -15,7 +15,7 @@ RSpec.describe Gitlab::Auth::IpRateLimiter, :use_clean_rails_memory_store_cachin } end - subject { described_class.new(ip) } + subject(:rate_limiter) { described_class.new(ip) } before do stub_rack_attack_setting(options) @@ -25,7 +25,7 @@ RSpec.describe Gitlab::Auth::IpRateLimiter, :use_clean_rails_memory_store_cachin end after do - subject.reset! + rate_limiter.reset! end describe '#register_fail!' do @@ -86,7 +86,7 @@ RSpec.describe Gitlab::Auth::IpRateLimiter, :use_clean_rails_memory_store_cachin end end - context 'when IP is whitlisted' do + context 'when IP is allow listed' do let(:ip) { '127.0.0.1' } it_behaves_like 'skips the rate limiter' @@ -97,4 +97,20 @@ RSpec.describe Gitlab::Auth::IpRateLimiter, :use_clean_rails_memory_store_cachin it_behaves_like 'skips the rate limiter' end + + describe '#trusted_ip?' do + subject { rate_limiter.trusted_ip? } + + context 'when ip is in the trusted list' do + let(:ip) { '127.0.0.1' } + + it { is_expected.to be_truthy } + end + + context 'when ip is not in the trusted list' do + let(:ip) { '10.0.0.1' } + + it { is_expected.to be_falsey } + end + end end |