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:
Diffstat (limited to 'spec/factories/ci/reports')
-rw-r--r--spec/factories/ci/reports/sbom/components.rb19
-rw-r--r--spec/factories/ci/reports/sbom/sources.rb34
2 files changed, 53 insertions, 0 deletions
diff --git a/spec/factories/ci/reports/sbom/components.rb b/spec/factories/ci/reports/sbom/components.rb
new file mode 100644
index 00000000000..317e1c863cf
--- /dev/null
+++ b/spec/factories/ci/reports/sbom/components.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :ci_reports_sbom_component, class: '::Gitlab::Ci::Reports::Sbom::Component' do
+ type { :library }
+ sequence(:name) { |n| "component-#{n}" }
+ sequence(:version) { |n| "v0.0.#{n}" }
+
+ skip_create
+
+ initialize_with do
+ ::Gitlab::Ci::Reports::Sbom::Component.new(
+ type: type,
+ name: name,
+ version: version
+ )
+ end
+ end
+end
diff --git a/spec/factories/ci/reports/sbom/sources.rb b/spec/factories/ci/reports/sbom/sources.rb
new file mode 100644
index 00000000000..9093aba86a6
--- /dev/null
+++ b/spec/factories/ci/reports/sbom/sources.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+FactoryBot.define do
+ factory :ci_reports_sbom_source, class: '::Gitlab::Ci::Reports::Sbom::Source' do
+ type { :dependency_scanning }
+
+ transient do
+ sequence(:input_file_path) { |n| "subproject-#{n}/package-lock.json" }
+ sequence(:source_file_path) { |n| "subproject-#{n}/package.json" }
+ end
+
+ data do
+ {
+ 'category' => 'development',
+ 'input_file' => { 'path' => input_file_path },
+ 'source_file' => { 'path' => source_file_path },
+ 'package_manager' => { 'name' => 'npm' },
+ 'language' => { 'name' => 'JavaScript' }
+ }
+ end
+
+ fingerprint { Digest::SHA256.hexdigest(data.to_json) }
+
+ skip_create
+
+ initialize_with do
+ ::Gitlab::Ci::Reports::Sbom::Source.new(
+ type: type,
+ data: data,
+ fingerprint: fingerprint
+ )
+ end
+ end
+end