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

clientside_preview_csp_spec.rb « ide « features « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: eadcb9cd008dc0668dc4f9bdd496d156d553fb03 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'IDE Clientside Preview CSP' do
  let_it_be(:user) { create(:user) }

  shared_context 'disable feature' do
    before do
      allow_next_instance_of(ApplicationSetting) do |instance|
        allow(instance).to receive(:web_ide_clientside_preview_enabled?).and_return(false)
      end
    end
  end

  it_behaves_like 'setting CSP', 'frame-src' do
    let(:whitelisted_url) { 'https://sandbox.gitlab-static.test' }
    let(:extended_controller_class) { IdeController }

    subject do
      visit ide_path

      response_headers['Content-Security-Policy']
    end

    before do
      allow_next_instance_of(ApplicationSetting) do |instance|
        allow(instance).to receive(:web_ide_clientside_preview_enabled?).and_return(true)
        allow(instance).to receive(:web_ide_clientside_preview_bundler_url).and_return(whitelisted_url)
      end

      sign_in(user)
    end
  end
end