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-05-19 18:44:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-05-19 18:44:42 +0300
commit4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch)
tree5423a1c7516cffe36384133ade12572cf709398d /spec/services/security
parente570267f2f6b326480d284e0164a6464ba4081bc (diff)
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/services/security')
-rw-r--r--spec/services/security/ci_configuration/sast_create_service_spec.rb75
-rw-r--r--spec/services/security/ci_configuration/secret_detection_create_service_spec.rb19
2 files changed, 35 insertions, 59 deletions
diff --git a/spec/services/security/ci_configuration/sast_create_service_spec.rb b/spec/services/security/ci_configuration/sast_create_service_spec.rb
index ff7ab614e08..44f8f07a5be 100644
--- a/spec/services/security/ci_configuration/sast_create_service_spec.rb
+++ b/spec/services/security/ci_configuration/sast_create_service_spec.rb
@@ -3,67 +3,24 @@
require 'spec_helper'
RSpec.describe Security::CiConfiguration::SastCreateService, :snowplow do
- describe '#execute' do
- let_it_be(:project) { create(:project, :repository) }
- let_it_be(:user) { create(:user) }
- let(:params) { {} }
+ subject(:result) { described_class.new(project, user, params).execute }
- subject(:result) { described_class.new(project, user, params).execute }
+ let(:branch_name) { 'set-sast-config-1' }
- context 'user does not belong to project' do
- it 'returns an error status' do
- expect(result[:status]).to eq(:error)
- expect(result[:success_path]).to be_nil
- end
-
- it 'does not track a snowplow event' do
- subject
-
- expect_no_snowplow_event
- end
- end
-
- context 'user belongs to project' do
- before do
- project.add_developer(user)
- end
-
- it 'does track the snowplow event' do
- subject
-
- expect_snowplow_event(
- category: 'Security::CiConfiguration::SastCreateService',
- action: 'create',
- label: 'false'
- )
- end
-
- it 'raises exception if the user does not have permission to create a new branch' do
- allow(project).to receive(:repository).and_raise(Gitlab::Git::PreReceiveError, "You are not allowed to create protected branches on this project.")
-
- expect { subject }.to raise_error(Gitlab::Git::PreReceiveError)
- end
-
- context 'with no parameters' do
- it 'returns the path to create a new merge request' do
- expect(result[:status]).to eq(:success)
- expect(result[:success_path]).to match(/#{Gitlab::Routing.url_helpers.project_new_merge_request_url(project, {})}(.*)description(.*)source_branch/)
- end
- end
-
- context 'with parameters' do
- let(:params) do
- { 'stage' => 'security',
- 'SEARCH_MAX_DEPTH' => 1,
- 'SECURE_ANALYZERS_PREFIX' => 'new_registry',
- 'SAST_EXCLUDED_PATHS' => 'spec,docs' }
- end
+ let(:non_empty_params) do
+ { 'stage' => 'security',
+ 'SEARCH_MAX_DEPTH' => 1,
+ 'SECURE_ANALYZERS_PREFIX' => 'new_registry',
+ 'SAST_EXCLUDED_PATHS' => 'spec,docs' }
+ end
- it 'returns the path to create a new merge request' do
- expect(result[:status]).to eq(:success)
- expect(result[:success_path]).to match(/#{Gitlab::Routing.url_helpers.project_new_merge_request_url(project, {})}(.*)description(.*)source_branch/)
- end
- end
- end
+ let(:snowplow_event) do
+ {
+ category: 'Security::CiConfiguration::SastCreateService',
+ action: 'create',
+ label: 'false'
+ }
end
+
+ include_examples 'services security ci configuration create service'
end
diff --git a/spec/services/security/ci_configuration/secret_detection_create_service_spec.rb b/spec/services/security/ci_configuration/secret_detection_create_service_spec.rb
new file mode 100644
index 00000000000..c1df3ebdca5
--- /dev/null
+++ b/spec/services/security/ci_configuration/secret_detection_create_service_spec.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Security::CiConfiguration::SecretDetectionCreateService, :snowplow do
+ subject(:result) { described_class.new(project, user).execute }
+
+ let(:branch_name) { 'set-secret-detection-config-1' }
+
+ let(:snowplow_event) do
+ {
+ category: 'Security::CiConfiguration::SecretDetectionCreateService',
+ action: 'create',
+ label: ''
+ }
+ end
+
+ include_examples 'services security ci configuration create service', true
+end