blob: b79a0427ef64112eb8ee73c84e1509c5c4782e56 (
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 'Tracings Content Security Policy' do
include ContentSecurityPolicyHelpers
let_it_be(:project) { create(:project) }
let_it_be(:user) { create(:user) }
subject { response_headers['Content-Security-Policy'] }
before_all do
project.add_maintainer(user)
end
before do
sign_in(user)
end
context 'when there is no global config' do
before do
setup_csp_for_controller(Projects::TracingsController)
end
it 'does not add CSP directives' do
visit project_tracing_path(project)
is_expected.to be_blank
end
end
context 'when a global CSP config exists' do
before do
csp = ActionDispatch::ContentSecurityPolicy.new do |p|
p.frame_src 'https://global-policy.com'
end
setup_existing_csp_for_controller(Projects::TracingsController, csp)
end
context 'when external_url is set' do
let!(:project_tracing_setting) { create(:project_tracing_setting, project: project) }
it 'overwrites frame-src' do
visit project_tracing_path(project)
is_expected.to eq("frame-src https://example.com")
end
end
context 'when external_url is not set' do
it 'uses global policy' do
visit project_tracing_path(project)
is_expected.to eq("frame-src https://global-policy.com")
end
end
end
end
|