Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-04 00:06:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-04 00:06:23 +0300
commit4529c19950e412f0461910585414f8633d3b1b18 (patch)
tree00b75c579ef52b41fea09c516cd5286dee5df703 /spec/lib/gitlab/auth
parentab7cf450ba19cf80b9534f25dc707b33845e3014 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/auth')
-rw-r--r--spec/lib/gitlab/auth/ip_rate_limiter_spec.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb b/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb
index 8d6bf45ab30..aea1b2921b6 100644
--- a/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb
+++ b/spec/lib/gitlab/auth/ip_rate_limiter_spec.rb
@@ -62,4 +62,36 @@ describe Gitlab::Auth::IpRateLimiter, :use_clean_rails_memory_store_caching do
it_behaves_like 'whitelisted IPs'
end
end
+
+ shared_examples 'skips the rate limiter' do
+ it 'does not call Rack::Attack::Allow2Ban.reset!' do
+ expect(Rack::Attack::Allow2Ban).not_to receive(:reset!)
+
+ subject.reset!
+ end
+
+ it 'does not call Rack::Attack::Allow2Ban.banned?' do
+ expect(Rack::Attack::Allow2Ban).not_to receive(:banned?)
+
+ subject.banned?
+ end
+
+ it 'does not call Rack::Attack::Allow2Ban.filter' do
+ expect(Rack::Attack::Allow2Ban).not_to receive(:filter)
+
+ subject.register_fail!
+ end
+ end
+
+ context 'when IP is whitlisted' do
+ let(:ip) { '127.0.0.1' }
+
+ it_behaves_like 'skips the rate limiter'
+ end
+
+ context 'when rate limiter is disabled' do
+ let(:options) { { enabled: false } }
+
+ it_behaves_like 'skips the rate limiter'
+ end
end