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

application_spec.rb « config « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5bb3b69de019d20b438f53bbe7840ace57b9d0de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Application, feature_category: :scalability do # rubocop:disable RSpec/FilePath
  describe 'config.filter_parameters' do
    using RSpec::Parameterized::TableSyntax

    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

          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&noteable=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

        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

        expect(ActiveRecord::Base.connection_handler.active_connections?).to eq(false)
      end
    end
  end
end