diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-19 15:57:54 +0300 |
commit | 419c53ec62de6e97a517abd5fdd4cbde3a942a34 (patch) | |
tree | 1f43a548b46bca8a5fb8fe0c31cef1883d49c5b6 /spec/initializers | |
parent | 1da20d9135b3ad9e75e65b028bffc921aaf8deb7 (diff) |
Add latest changes from gitlab-org/gitlab@16-5-stable-eev16.5.0-rc42
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/direct_upload_support_spec.rb | 2 | ||||
-rw-r--r-- | spec/initializers/enumerator_next_patch_spec.rb | 6 | ||||
-rw-r--r-- | spec/initializers/gitlab_http_spec.rb | 47 | ||||
-rw-r--r-- | spec/initializers/hangouts_chat_http_override_spec.rb | 34 | ||||
-rw-r--r-- | spec/initializers/net_http_patch_spec.rb | 8 | ||||
-rw-r--r-- | spec/initializers/net_http_response_patch_spec.rb | 3 | ||||
-rw-r--r-- | spec/initializers/rack_multipart_patch_spec.rb | 4 | ||||
-rw-r--r-- | spec/initializers/validate_database_config_spec.rb | 5 | ||||
-rw-r--r-- | spec/initializers/validate_puma_spec.rb | 16 |
9 files changed, 65 insertions, 60 deletions
diff --git a/spec/initializers/direct_upload_support_spec.rb b/spec/initializers/direct_upload_support_spec.rb index 68dd12fdb6e..29d19c8397c 100644 --- a/spec/initializers/direct_upload_support_spec.rb +++ b/spec/initializers/direct_upload_support_spec.rb @@ -8,7 +8,7 @@ RSpec.describe 'Direct upload support' do end where(:config_name) do - %w(artifacts lfs uploads) + %w[artifacts lfs uploads] end with_them do diff --git a/spec/initializers/enumerator_next_patch_spec.rb b/spec/initializers/enumerator_next_patch_spec.rb index 99e73af5e86..bf8ab823e53 100644 --- a/spec/initializers/enumerator_next_patch_spec.rb +++ b/spec/initializers/enumerator_next_patch_spec.rb @@ -33,15 +33,15 @@ RSpec.describe 'Enumerator#next patch fix' do end def have_been_raised_by_next_and_not_fixed_up - contain_unique_method_calls_in_order %w(call_enum_method) + contain_unique_method_calls_in_order %w[call_enum_method] end def have_been_raised_by_enum_object_and_fixed_up - contain_unique_method_calls_in_order %w(make_error call_enum_method) + contain_unique_method_calls_in_order %w[make_error call_enum_method] end def have_been_raised_by_nested_next_and_fixed_up - contain_unique_method_calls_in_order %w(call_nested_next call_enum_method) + contain_unique_method_calls_in_order %w[call_nested_next call_enum_method] end methods = [ diff --git a/spec/initializers/gitlab_http_spec.rb b/spec/initializers/gitlab_http_spec.rb new file mode 100644 index 00000000000..7715112abf4 --- /dev/null +++ b/spec/initializers/gitlab_http_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::HTTP_V2, feature_category: :shared do + it 'handles log_exception_proc' do + expect(Gitlab::HTTP_V2::Client).to receive(:httparty_perform_request) + .and_raise(Net::ReadTimeout) + + expect(Gitlab::ErrorTracking).to receive(:log_exception) + .with(Net::ReadTimeout, {}) + + expect { described_class.get('http://example.org') }.to raise_error(Net::ReadTimeout) + end + + context 'when silent_mode_enabled is true' do + before do + stub_application_setting(silent_mode_enabled: true) + end + + context 'when sending a POST request' do + it 'handles silent_mode_log_info_proc' do + expect(::Gitlab::AppJsonLogger).to receive(:info).with( + message: "Outbound HTTP request blocked", + outbound_http_request_method: 'Net::HTTP::Post', + silent_mode_enabled: true + ) + + expect { described_class.post('http://example.org', silent_mode_enabled: true) }.to raise_error( + Gitlab::HTTP_V2::SilentModeBlockedError + ) + end + end + + context 'when sending a GET request' do + before do + stub_request(:get, 'http://example.org').to_return(body: 'hello') + end + + it 'does not raise an error' do + expect(::Gitlab::AppJsonLogger).not_to receive(:info) + + expect(described_class.get('http://example.org', silent_mode_enabled: true).body).to eq('hello') + end + end + end +end diff --git a/spec/initializers/hangouts_chat_http_override_spec.rb b/spec/initializers/hangouts_chat_http_override_spec.rb deleted file mode 100644 index 42236c8c853..00000000000 --- a/spec/initializers/hangouts_chat_http_override_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'HangoutsChat::Sender Gitlab::HTTP override' do - describe 'HangoutsChat::Sender::HTTP#post' do - it 'calls Gitlab::HTTP.post with default protection settings' do - webhook_url = 'https://example.gitlab.com' - payload = { key: 'value' } - http = HangoutsChat::Sender::HTTP.new(webhook_url) - mock_response = double(response: 'the response') - - expect(Gitlab::HTTP).to receive(:post) - .with( - URI.parse(webhook_url), - body: payload.to_json, - headers: { 'Content-Type' => 'application/json' }, - parse: nil - ) - .and_return(mock_response) - - expect(http.post(payload)).to eq(mock_response.response) - end - - it_behaves_like 'a request using Gitlab::UrlBlocker' do - let(:http_method) { :post } - let(:url_blocked_error_class) { Gitlab::HTTP::BlockedUrlError } - - def make_request(uri) - HangoutsChat::Sender::HTTP.new(uri).post({}) - end - end - end -end diff --git a/spec/initializers/net_http_patch_spec.rb b/spec/initializers/net_http_patch_spec.rb index b9f5299b58c..959eae954c4 100644 --- a/spec/initializers/net_http_patch_spec.rb +++ b/spec/initializers/net_http_patch_spec.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'fast_spec_helper' -require 'net/http' +# TODO: This spec file can be removed after fully migration to the gitlab-http gem. +# It's already covered in gems/gitlab-http/spec/gitlab/http_v2/net_http_patch_spec.rb -require_relative '../../config/initializers/net_http_patch' +require 'spec_helper' -RSpec.describe 'Net::HTTP patch proxy user and password encoding' do +RSpec.describe 'Net::HTTP patch proxy user and password encoding', feature_category: :shared do let(:net_http) { Net::HTTP.new('hostname.example') } before do diff --git a/spec/initializers/net_http_response_patch_spec.rb b/spec/initializers/net_http_response_patch_spec.rb index cd261d7b997..8074047d6aa 100644 --- a/spec/initializers/net_http_response_patch_spec.rb +++ b/spec/initializers/net_http_response_patch_spec.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +# TODO: This spec file can be removed after fully migration to the gitlab-http gem. +# It's already covered in gems/gitlab-http/spec/gitlab/http_v2/net_http_response_patch_spec.rb + require 'spec_helper' RSpec.describe 'Net::HTTPResponse patch header read timeout', feature_category: :shared do diff --git a/spec/initializers/rack_multipart_patch_spec.rb b/spec/initializers/rack_multipart_patch_spec.rb index 862fdc7901b..4b46da73236 100644 --- a/spec/initializers/rack_multipart_patch_spec.rb +++ b/spec/initializers/rack_multipart_patch_spec.rb @@ -37,7 +37,7 @@ EOF expect(described_class).not_to receive(:log_multipart_warning) params = described_class.parse_multipart(env) - expect(params.keys).to include(*%w(reply fileupload)) + expect(params.keys).to include(*%w[reply fileupload]) end end @@ -56,7 +56,7 @@ EOF }) params = described_class.parse_multipart(env) - expect(params.keys).to include(*%w(reply fileupload)) + expect(params.keys).to include(*%w[reply fileupload]) end end diff --git a/spec/initializers/validate_database_config_spec.rb b/spec/initializers/validate_database_config_spec.rb index 23a3d9a2950..ffafe937ba9 100644 --- a/spec/initializers/validate_database_config_spec.rb +++ b/spec/initializers/validate_database_config_spec.rb @@ -3,7 +3,6 @@ require 'spec_helper' RSpec.describe 'validate database config' do - include RakeHelpers include StubENV let(:rails_configuration) { Rails::Application::Configuration.new(Rails.root) } @@ -50,9 +49,7 @@ RSpec.describe 'validate database config' do end it 'validates configuration without errors and warnings' do - expect(main_object).not_to receive(:warn) - - expect { subject }.not_to raise_error + expect { subject }.not_to output.to_stderr end end diff --git a/spec/initializers/validate_puma_spec.rb b/spec/initializers/validate_puma_spec.rb index 9ff0ef2c319..c46effd6525 100644 --- a/spec/initializers/validate_puma_spec.rb +++ b/spec/initializers/validate_puma_spec.rb @@ -3,8 +3,6 @@ require 'spec_helper' RSpec.describe 'validate puma' do - include RakeHelpers - subject do load Rails.root.join('config/initializers/validate_puma.rb') end @@ -36,8 +34,6 @@ RSpec.describe 'validate puma' do context 'for other environments' do before do allow(Gitlab).to receive(:com?).and_return(false) - - allow(main_object).to receive(:warn) end context 'when worker count is 0' do @@ -46,21 +42,17 @@ RSpec.describe 'validate puma' do specify { expect { subject }.not_to raise_error } it 'warns about running Puma in a Single mode' do - expect(main_object).to receive(:warn) do |warning| - expect(warning).to include('https://gitlab.com/groups/gitlab-org/-/epics/5303') - end - - subject + expect { subject } + .to output(%r{https://gitlab.com/groups/gitlab-org/-/epics/5303}) + .to_stderr end end context 'when worker count is > 0' do let(:workers) { 2 } - specify { expect { subject }.not_to raise_error } - it 'does not issue a warning' do - expect(main_object).not_to receive(:warn) + expect { subject }.not_to output.to_stderr end end end |