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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-07 17:47:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-07 17:47:00 +0300
commit08086ff522742c28a6b10e9b2ed71f0af6633e5b (patch)
tree5a4fde8b23140cb4edf04b24854b53f87085dd42 /spec/lib/gitlab/content_security_policy
parent8f3fbbf0d56091ad87158f61bf2a4e96a7f937e3 (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-ee
Diffstat (limited to 'spec/lib/gitlab/content_security_policy')
-rw-r--r--spec/lib/gitlab/content_security_policy/config_loader_spec.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/spec/lib/gitlab/content_security_policy/config_loader_spec.rb b/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
index 41a6c06f9c9..19e52d2cf4a 100644
--- a/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
+++ b/spec/lib/gitlab/content_security_policy/config_loader_spec.rb
@@ -20,9 +20,9 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
end
describe '.default_settings_hash' do
- it 'returns defaults for all keys' do
- settings = described_class.default_settings_hash
+ let(:settings) { described_class.default_settings_hash }
+ it 'returns defaults for all keys' do
expect(settings['enabled']).to be_truthy
expect(settings['report_only']).to be_falsey
@@ -35,6 +35,17 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
expect(directives.has_key?('report_uri')).to be_truthy
expect(directives['report_uri']).to be_nil
+ expect(directives['child_src']).to eq(directives['frame_src'])
+ end
+
+ context 'when in production' do
+ before do
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
+ end
+
+ it 'is disabled' do
+ expect(settings['enabled']).to be_falsey
+ end
end
context 'when GITLAB_CDN_HOST is set' do
@@ -43,10 +54,9 @@ RSpec.describe Gitlab::ContentSecurityPolicy::ConfigLoader do
end
it 'adds GITLAB_CDN_HOST to CSP' do
- settings = described_class.default_settings_hash
directives = settings['directives']
- expect(directives['script_src']).to eq("'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.recaptcha.net https://apis.google.com https://example.com")
+ expect(directives['script_src']).to eq("'strict-dynamic' 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com/recaptcha/ https://www.recaptcha.net https://apis.google.com https://example.com")
expect(directives['style_src']).to eq("'self' 'unsafe-inline' https://example.com")
end
end