2019-07-25 05:11:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-14 00:13:44 +00:00
|
|
|
FactoryBot.define do
|
2020-01-09 18:07:52 +00:00
|
|
|
factory :ci_job_artifact, class: 'Ci::JobArtifact' do
|
2017-09-21 08:34:12 +00:00
|
|
|
job factory: :ci_build
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :archive }
|
|
|
|
file_format { :zip }
|
2017-09-21 08:34:12 +00:00
|
|
|
|
2019-08-24 21:16:44 +00:00
|
|
|
trait :expired do
|
|
|
|
expire_at { Date.yesterday }
|
|
|
|
end
|
|
|
|
|
2017-12-05 14:31:33 +00:00
|
|
|
trait :remote_store do
|
2020-04-15 18:09:36 +00:00
|
|
|
file_store { JobArtifactUploader::Store::REMOTE}
|
2017-12-05 14:31:33 +00:00
|
|
|
end
|
|
|
|
|
2017-11-02 11:16:50 +00:00
|
|
|
after :build do |artifact|
|
|
|
|
artifact.project ||= artifact.job.project
|
|
|
|
end
|
|
|
|
|
2018-09-27 21:15:08 +00:00
|
|
|
trait :raw do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :raw }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :zip do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :zip }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :gzip do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_format { :gzip }
|
2018-09-27 21:15:08 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-11-23 17:51:20 +00:00
|
|
|
trait :archive do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :archive }
|
|
|
|
file_format { :zip }
|
2017-11-30 17:32:16 +00:00
|
|
|
|
2019-03-22 12:38:45 +00:00
|
|
|
transient do
|
|
|
|
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip') }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = evaluator.file
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-17 04:33:15 +00:00
|
|
|
trait :legacy_archive do
|
|
|
|
archive
|
|
|
|
|
2019-10-02 00:06:26 +00:00
|
|
|
file_location { :legacy_path }
|
2018-08-17 04:33:15 +00:00
|
|
|
end
|
|
|
|
|
2017-11-23 17:51:20 +00:00
|
|
|
trait :metadata do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :metadata }
|
|
|
|
file_format { :gzip }
|
2017-11-30 17:32:16 +00:00
|
|
|
|
2019-03-22 12:38:45 +00:00
|
|
|
transient do
|
|
|
|
file { fixture_file_upload(Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip') }
|
|
|
|
end
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = evaluator.file
|
2017-11-23 17:51:20 +00:00
|
|
|
end
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
2018-02-06 14:18:32 +00:00
|
|
|
|
|
|
|
trait :trace do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :trace }
|
|
|
|
file_format { :raw }
|
2018-02-06 14:18:32 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
|
|
|
|
end
|
|
|
|
end
|
2018-03-06 18:46:36 +00:00
|
|
|
|
2018-07-27 05:04:35 +00:00
|
|
|
trait :junit do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-07-27 05:04:35 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2018-08-02 08:15:25 +00:00
|
|
|
Rails.root.join('spec/fixtures/junit/junit.xml.gz'), 'application/x-gzip')
|
2018-07-27 05:04:35 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-03 06:09:14 +00:00
|
|
|
trait :junit_with_attachment do
|
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_attachment.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-10-23 18:08:31 +00:00
|
|
|
trait :junit_with_duplicate_failed_test_names do
|
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_duplicate_failed_test_names.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-08-02 06:05:07 +00:00
|
|
|
trait :junit_with_ant do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2018-08-02 08:15:25 +00:00
|
|
|
Rails.root.join('spec/fixtures/junit/junit_ant.xml.gz'), 'application/x-gzip')
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :junit_with_three_testsuites do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_three_testsuites.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :junit_with_corrupted_data do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
2018-08-02 06:05:07 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_corrupted_data.xml.gz'), 'application/x-gzip')
|
2020-03-17 18:09:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-11-02 09:08:35 +00:00
|
|
|
trait :junit_with_three_failures do
|
|
|
|
file_type { :junit }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/junit/junit_with_three_failures.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-23 03:09:51 +00:00
|
|
|
trait :accessibility do
|
|
|
|
file_type { :accessibility }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/accessibility/pa11y_with_errors.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :accessibility_with_invalid_url do
|
|
|
|
file_type { :accessibility }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/accessibility/pa11y_with_invalid_url.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :accessibility_without_errors do
|
|
|
|
file_type { :accessibility }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/accessibility/pa11y_without_errors.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-17 18:09:44 +00:00
|
|
|
trait :cobertura do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-21 15:21:10 +00:00
|
|
|
trait :terraform do
|
|
|
|
file_type { :terraform }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/terraform/tfplan.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :terraform_with_corrupted_data do
|
|
|
|
file_type { :terraform }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/terraform/tfplan_with_corrupted_data.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-17 18:09:44 +00:00
|
|
|
trait :coverage_gocov_xml do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage_gocov_xml.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
2020-12-04 15:09:36 +00:00
|
|
|
|
|
|
|
trait :coverage_with_paths_not_relative_to_project_root do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage_with_paths_not_relative_to_project_root.xml.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
2020-03-17 18:09:44 +00:00
|
|
|
|
|
|
|
trait :coverage_with_corrupted_data do
|
|
|
|
file_type { :cobertura }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/cobertura/coverage_with_corrupted_data.xml.gz'), 'application/x-gzip')
|
2018-08-02 06:05:07 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-10-02 17:01:26 +00:00
|
|
|
trait :codequality do
|
2019-10-02 00:06:26 +00:00
|
|
|
file_type { :codequality }
|
|
|
|
file_format { :raw }
|
2018-10-02 17:01:26 +00:00
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
2020-11-23 15:09:37 +00:00
|
|
|
Rails.root.join('spec/fixtures/codequality/codeclimate.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :codequality_without_errors do
|
|
|
|
file_type { :codequality }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/codequality/codeclimate_without_errors.json'), 'application/json')
|
2018-10-02 17:01:26 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-10 09:09:38 +00:00
|
|
|
trait :sast do
|
|
|
|
file_type { :sast }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-sast-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-05 00:10:41 +00:00
|
|
|
trait :sast_minimal do
|
|
|
|
file_type { :sast }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-sast-report-minimal.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-02 15:08:56 +00:00
|
|
|
trait :common_security_report do
|
|
|
|
file_format { :raw }
|
|
|
|
file_type { :dependency_scanning }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-common-scanning-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :common_security_report_with_blank_names do
|
|
|
|
file_format { :raw }
|
|
|
|
file_type { :dependency_scanning }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-common-scanning-report-names.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :sast_deprecated do
|
|
|
|
file_type { :sast }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/deprecated/gl-sast-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :sast_with_corrupted_data do
|
|
|
|
file_type { :sast }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/trace/sample_trace'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :sast_feature_branch do
|
|
|
|
file_format { :raw }
|
|
|
|
file_type { :sast }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/feature-branch/gl-sast-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :secret_detection_feature_branch do
|
|
|
|
file_format { :raw }
|
|
|
|
file_type { :secret_detection }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/feature-branch/gl-secret-detection-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
trait :sast_with_missing_scanner do
|
|
|
|
file_type { :sast }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-sast-missing-scanner.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-10 09:09:38 +00:00
|
|
|
trait :secret_detection do
|
|
|
|
file_type { :secret_detection }
|
|
|
|
file_format { :raw }
|
|
|
|
|
|
|
|
after(:build) do |artifact, _|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/security_reports/master/gl-secret-detection-report.json'), 'application/json')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-10 15:08:54 +00:00
|
|
|
trait :lsif do
|
|
|
|
file_type { :lsif }
|
2020-05-15 18:07:52 +00:00
|
|
|
file_format { :zip }
|
|
|
|
|
2020-02-10 15:08:54 +00:00
|
|
|
after(:build) do |artifact, evaluator|
|
2020-05-27 06:08:13 +00:00
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/lsif.json.zip'), 'application/zip')
|
2020-02-10 15:08:54 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-13 21:09:38 +00:00
|
|
|
trait :dotenv do
|
|
|
|
file_type { :dotenv }
|
|
|
|
file_format { :gzip }
|
|
|
|
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file = fixture_file_upload(
|
|
|
|
Rails.root.join('spec/fixtures/build.env.gz'), 'application/x-gzip')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-06 18:46:36 +00:00
|
|
|
trait :correct_checksum do
|
|
|
|
after(:build) do |artifact, evaluator|
|
|
|
|
artifact.file_sha256 = Digest::SHA256.file(artifact.file.path).hexdigest
|
|
|
|
end
|
|
|
|
end
|
2017-09-21 08:34:12 +00:00
|
|
|
end
|
|
|
|
end
|