diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 15:07:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-15 15:07:58 +0300 |
commit | f26f31d2fd8e3c91677e2629293b9e0562c1437a (patch) | |
tree | 5a689004863bee4374c16920663221ea81afe664 /spec/config | |
parent | 50e177d19bdeeb0fcc7b129b9c30841454df240b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/config')
-rw-r--r-- | spec/config/application_spec.rb | 64 |
1 files changed, 45 insertions, 19 deletions
diff --git a/spec/config/application_spec.rb b/spec/config/application_spec.rb index 7b64ad4a9b9..5bb3b69de01 100644 --- a/spec/config/application_spec.rb +++ b/spec/config/application_spec.rb @@ -3,31 +3,57 @@ require 'spec_helper' RSpec.describe Gitlab::Application, feature_category: :scalability do # rubocop:disable RSpec/FilePath - using RSpec::Parameterized::TableSyntax + describe 'config.filter_parameters' do + using RSpec::Parameterized::TableSyntax - filtered_param = ActiveSupport::ParameterFilter::FILTERED + filtered = ActiveSupport::ParameterFilter::FILTERED - context 'when parameters are logged' do - describe 'rails does not leak confidential parameters' do - def request_for_url(input_url) - env = Rack::MockRequest.env_for(input_url) - env['action_dispatch.parameter_filter'] = described_class.config.filter_parameters + context 'when parameters are logged' do + describe 'rails does not leak confidential parameters' do + def request_for_url(input_url) + env = Rack::MockRequest.env_for(input_url) + env['action_dispatch.parameter_filter'] = described_class.config.filter_parameters - ActionDispatch::Request.new(env) - end + ActionDispatch::Request.new(env) + end + + where(:input_url, :output_query) do + '/' | {} + '/?safe=1' | { 'safe' => '1' } + '/?private_token=secret' | { 'private_token' => filtered } + '/?mixed=1&private_token=secret' | { 'mixed' => '1', 'private_token' => filtered } + '/?note=secret¬eable=1&prefix_note=2' | { 'note' => filtered, 'noteable' => '1', 'prefix_note' => '2' } + '/?note[note]=secret&target_type=1' | { 'note' => filtered, 'target_type' => '1' } + '/?safe[note]=secret&target_type=1' | { 'safe' => { 'note' => filtered }, 'target_type' => '1' } + end - where(:input_url, :output_query) do - '/' | {} - '/?safe=1' | { 'safe' => '1' } - '/?private_token=secret' | { 'private_token' => filtered_param } - '/?mixed=1&private_token=secret' | { 'mixed' => '1', 'private_token' => filtered_param } - '/?note=secret¬eable=1&prefix_note=2' | { 'note' => filtered_param, 'noteable' => '1', 'prefix_note' => '2' } - '/?note[note]=secret&target_type=1' | { 'note' => filtered_param, 'target_type' => '1' } - '/?safe[note]=secret&target_type=1' | { 'safe' => { 'note' => filtered_param }, 'target_type' => '1' } + with_them do + it { expect(request_for_url(input_url).filtered_parameters).to eq(output_query) } + end end + end + end + + describe 'clear_active_connections_again initializer' do + subject(:clear_active_connections_again) do + described_class.initializers.find { |i| i.name == :clear_active_connections_again } + end + + it 'is included in list of Rails initializers' do + expect(clear_active_connections_again).to be_present + end + + it 'is configured after set_routes_reloader_hook' do + expect(clear_active_connections_again.after).to eq(:set_routes_reloader_hook) + end + + describe 'functionality', :reestablished_active_record_base do + it 'clears all connections' do + Project.first + + clear_active_connections_again.run - with_them do - it { expect(request_for_url(input_url).filtered_parameters).to eq(output_query) } + expect(ActiveRecord::Base.connection_handler.active_connections?).to eq(false) end end end |