diff --git a/lib/gitlab/rack_attack/request.rb b/lib/gitlab/rack_attack/request.rb index 97c8b84faf4790ab8c56919dde9b05f46d04787b..51fa35d7454f94fa960baab52361386c728c5d89 100644 --- a/lib/gitlab/rack_attack/request.rb +++ b/lib/gitlab/rack_attack/request.rb @@ -183,10 +183,7 @@ def throttle_unauthenticated_git_http? def throttle_authenticated_git_http? git_path? && - ( - Gitlab::Throttle.settings.throttle_authenticated_git_http_enabled || - Gitlab::Throttle.settings.throttle_authenticated_web_enabled - ) + Gitlab::Throttle.settings.throttle_authenticated_git_http_enabled end def throttle_authenticated_git_lfs? diff --git a/lib/gitlab/throttle.rb b/lib/gitlab/throttle.rb index 365d087f5d73dc8a26c593670c4e3d8d24bd213e..b945c765edd0ac2d005ff4389745964b29a14363 100644 --- a/lib/gitlab/throttle.rb +++ b/lib/gitlab/throttle.rb @@ -79,10 +79,6 @@ def self.throttle_unauthenticated_git_http_options end def self.throttle_authenticated_git_http_options - if !settings.throttle_authenticated_git_http_enabled && settings.throttle_authenticated_web_enabled - return authenticated_web_options - end - limit_proc = proc { |req| settings.throttle_authenticated_git_http_requests_per_period } period_proc = proc { |req| settings.throttle_authenticated_git_http_period_in_seconds.seconds } diff --git a/spec/lib/gitlab/rack_attack/request_spec.rb b/spec/lib/gitlab/rack_attack/request_spec.rb index e3078af320f1943eeee281d8c5ac74f28c80f00d..2e56f5bbc229284376466f83f653b0830bd56cab 100644 --- a/spec/lib/gitlab/rack_attack/request_spec.rb +++ b/spec/lib/gitlab/rack_attack/request_spec.rb @@ -288,30 +288,6 @@ it { is_expected.to eq expected } end - - context 'when falls back for web requests' do - where(:git_http_enabled, :web_enabled, :expected) do - false | false | false - true | false | true - false | true | true - true | true | true - end - - with_them do - before do - stub_application_setting( - throttle_authenticated_git_http_enabled: git_http_enabled, - throttle_authenticated_web_enabled: web_enabled - ) - end - - it 'enables Git HTTP setttings if either web or Git HTTP rate limiter is enabled' do - expect(request).to receive(:git_path?).and_return(true) - - expect(request.throttle_authenticated_git_http?).to eq(expected) - end - end - end end describe '#throttle_authenticated_git_http?' do diff --git a/spec/lib/gitlab/throttle_spec.rb b/spec/lib/gitlab/throttle_spec.rb index 67c9fff6e6ee985efa3a98b6545d311c181a31ef..051ff837787c8688b50134e6decb63bd90e862ae 100644 --- a/spec/lib/gitlab/throttle_spec.rb +++ b/spec/lib/gitlab/throttle_spec.rb @@ -62,32 +62,18 @@ end describe '.throttle_authenticated_git_http_options' do - where(:git_http_enabled, :web_enabled, :expected_requests, :expected_period) do - false | false | 50 | 30 - false | true | 100 | 60 - true | false | 50 | 30 - true | true | 50 | 30 + before do + stub_application_setting( + throttle_authenticated_git_http_requests_per_period: 50, + throttle_authenticated_git_http_period_in_seconds: 30 + ) end - with_them do - before do - stub_application_setting( - throttle_authenticated_web_requests_per_period: 100, - throttle_authenticated_web_period_in_seconds: 60, - throttle_authenticated_git_http_requests_per_period: 50, - throttle_authenticated_git_http_period_in_seconds: 30, - - throttle_authenticated_git_http_enabled: git_http_enabled, - throttle_authenticated_web_enabled: web_enabled - ) - end + it 'returns correct options' do + options = described_class.throttle_authenticated_git_http_options - it 'returns correct options' do - options = described_class.throttle_authenticated_git_http_options - - expect(options[:limit].call).to eq(expected_requests) - expect(options[:period].call).to eq(expected_period) - end + expect(options[:limit].call).to eq(50) + expect(options[:period].call).to eq(30) end end end