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>2022-02-03 14:35:56 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-02-03 14:35:56 +0300
commit33bbb6aa7b6369fea0037f3d8a9243824e48f64f (patch)
tree18ae1428e70ddcfe1115f355ebdad6ad6f0a6e56 /spec/support
parent41fd6d4d38aaef723e501ff3ab38ae63e31d4efb (diff)
Add latest changes from gitlab-org/security/gitlab@14-7-stable-ee
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_contexts/models/concerns/integrations/enable_ssl_verification_shared_context.rb47
-rw-r--r--spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb10
2 files changed, 57 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/models/concerns/integrations/enable_ssl_verification_shared_context.rb b/spec/support/shared_contexts/models/concerns/integrations/enable_ssl_verification_shared_context.rb
new file mode 100644
index 00000000000..c698e06c2a2
--- /dev/null
+++ b/spec/support/shared_contexts/models/concerns/integrations/enable_ssl_verification_shared_context.rb
@@ -0,0 +1,47 @@
+# frozen_string_literal: true
+
+RSpec.shared_context Integrations::EnableSslVerification do
+ # This is added to the global setup, to make sure all calls to
+ # `Gitlab::HTTP` in the main model spec are passing the `verify:` option.
+ before do
+ allow(Gitlab::HTTP).to receive(:perform_request)
+ .with(anything, anything, include(verify: true))
+ .and_call_original
+ end
+
+ describe 'accessors' do
+ it { is_expected.to respond_to(:enable_ssl_verification) }
+ it { is_expected.to respond_to(:enable_ssl_verification?) }
+ end
+
+ describe '#initialize_properties' do
+ it 'enables the setting by default' do
+ expect(integration.enable_ssl_verification).to be(true)
+ end
+
+ it 'does not enable the setting if the record is already persisted' do
+ allow(integration).to receive(:new_record?).and_return(false)
+
+ integration.enable_ssl_verification = false
+ integration.send(:initialize_properties)
+
+ expect(integration.enable_ssl_verification).to be(false)
+ end
+
+ it 'does not enable the setting if a custom value was set' do
+ integration = described_class.new(enable_ssl_verification: false)
+
+ expect(integration.enable_ssl_verification).to be(false)
+ end
+ end
+
+ describe '#fields' do
+ it 'inserts the checkbox field after the first URL field, or at the end' do
+ names = integration.fields.pluck(:name)
+ url_index = names.index { |name| name.ends_with?('_url') }
+ insert_index = url_index ? url_index + 1 : names.size - 1
+
+ expect(names.index('enable_ssl_verification')).to eq insert_index
+ end
+ end
+end
diff --git a/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb b/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
index 1fa340a0cf4..ae72cb6ec5d 100644
--- a/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
+++ b/spec/support/shared_examples/models/integrations/has_web_hook_shared_examples.rb
@@ -37,6 +37,16 @@ RSpec.shared_examples Integrations::HasWebHook do
it 'returns a boolean' do
expect(integration.hook_ssl_verification).to be_in([true, false])
end
+
+ it 'delegates to #enable_ssl_verification if the concern is included' do
+ next unless integration.is_a?(Integrations::EnableSslVerification)
+
+ [true, false].each do |value|
+ integration.enable_ssl_verification = value
+
+ expect(integration.hook_ssl_verification).to be(value)
+ end
+ end
end
describe '#update_web_hook!' do