diff options
Diffstat (limited to 'spec/factories')
-rw-r--r-- | spec/factories/activity_pub/releases_subscriptions.rb | 26 | ||||
-rw-r--r-- | spec/factories/ai/service_access_tokens.rb | 5 | ||||
-rw-r--r-- | spec/factories/ci/build_trace_chunks.rb | 16 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 5 | ||||
-rw-r--r-- | spec/factories/ci/catalog/resources/components.rb | 2 | ||||
-rw-r--r-- | spec/factories/ci/pipeline_artifacts.rb | 8 | ||||
-rw-r--r-- | spec/factories/ci/reports/security/findings.rb | 2 | ||||
-rw-r--r-- | spec/factories/commit_statuses.rb | 4 | ||||
-rw-r--r-- | spec/factories/ml/model_metadata.rb | 10 | ||||
-rw-r--r-- | spec/factories/ml/models.rb | 6 | ||||
-rw-r--r-- | spec/factories/packages/npm/metadata_cache.rb | 10 | ||||
-rw-r--r-- | spec/factories/packages/nuget/symbol.rb | 1 | ||||
-rw-r--r-- | spec/factories/pages_domains.rb | 81 | ||||
-rw-r--r-- | spec/factories/projects.rb | 33 | ||||
-rw-r--r-- | spec/factories/snippet_repositories.rb | 8 | ||||
-rw-r--r-- | spec/factories/terraform/state_version.rb | 8 | ||||
-rw-r--r-- | spec/factories/users.rb | 4 | ||||
-rw-r--r-- | spec/factories/users/phone_number_validations.rb | 1 |
18 files changed, 194 insertions, 36 deletions
diff --git a/spec/factories/activity_pub/releases_subscriptions.rb b/spec/factories/activity_pub/releases_subscriptions.rb new file mode 100644 index 00000000000..b789188528a --- /dev/null +++ b/spec/factories/activity_pub/releases_subscriptions.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :activity_pub_releases_subscription, class: 'ActivityPub::ReleasesSubscription' do + project + subscriber_url { 'https://example.com/actor' } + status { :requested } + payload do + { + '@context': 'https://www.w3.org/ns/activitystreams', + id: 'https://example.com/actor#follow/1', + type: 'Follow', + actor: 'https://example.com/actor', + object: 'http://localhost/user/project/-/releases' + } + end + + trait :inbox do + subscriber_inbox_url { 'https://example.com/actor/inbox' } + end + + trait :shared_inbox do + shared_inbox_url { 'https://example.com/shared-inbox' } + end + end +end diff --git a/spec/factories/ai/service_access_tokens.rb b/spec/factories/ai/service_access_tokens.rb index 61abf4e1144..0598eed52c4 100644 --- a/spec/factories/ai/service_access_tokens.rb +++ b/spec/factories/ai/service_access_tokens.rb @@ -4,7 +4,6 @@ FactoryBot.define do factory :service_access_token, class: 'Ai::ServiceAccessToken' do token { SecureRandom.alphanumeric(10) } expires_at { Time.current + 1.day } - category { :code_suggestions } trait :active do expires_at { Time.current + 1.day } @@ -13,9 +12,5 @@ FactoryBot.define do trait :expired do expires_at { Time.current - 1.day } end - - trait :code_suggestions do - category { :code_suggestions } - end end end diff --git a/spec/factories/ci/build_trace_chunks.rb b/spec/factories/ci/build_trace_chunks.rb index 64a297932de..56d8fc23222 100644 --- a/spec/factories/ci/build_trace_chunks.rb +++ b/spec/factories/ci/build_trace_chunks.rb @@ -22,6 +22,22 @@ FactoryBot.define do data_store { :redis } end + trait :redis_trace_chunks_with_data do + data_store { :redis_trace_chunks } + + transient do + initial_data { 'test data' } + end + + after(:create) do |build_trace_chunk, evaluator| + Ci::BuildTraceChunks::RedisTraceChunks.new.set_data(build_trace_chunk, evaluator.initial_data) + end + end + + trait :redis_trace_chunks_without_data do + data_store { :redis_trace_chunks } + end + trait :database_with_data do data_store { :database } diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 867db96aaaf..18415a6079f 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -117,6 +117,11 @@ FactoryBot.define do status { 'running' } end + trait :waiting_for_callback do + started + status { 'waiting_for_callback' } + end + trait :pending do with_token queued_at { 'Di 29. Okt 09:50:59 CET 2013' } diff --git a/spec/factories/ci/catalog/resources/components.rb b/spec/factories/ci/catalog/resources/components.rb index 8feecc695bc..843ccb2b461 100644 --- a/spec/factories/ci/catalog/resources/components.rb +++ b/spec/factories/ci/catalog/resources/components.rb @@ -5,6 +5,6 @@ FactoryBot.define do version factory: :ci_catalog_resource_version catalog_resource { version.catalog_resource } project { version.project } - name { catalog_resource.name } + name { catalog_resource.project.name } end end diff --git a/spec/factories/ci/pipeline_artifacts.rb b/spec/factories/ci/pipeline_artifacts.rb index bdd390126dd..77b1ac5a9cc 100644 --- a/spec/factories/ci/pipeline_artifacts.rb +++ b/spec/factories/ci/pipeline_artifacts.rb @@ -22,14 +22,6 @@ FactoryBot.define do locked { :unlocked } end - trait :checksummed do - verification_checksum { 'abc' } - end - - trait :checksum_failure do - verification_failure { 'Could not calculate the checksum' } - end - trait :expired do expire_at { Date.yesterday } end diff --git a/spec/factories/ci/reports/security/findings.rb b/spec/factories/ci/reports/security/findings.rb index 202c2789b45..670d833c1f8 100644 --- a/spec/factories/ci/reports/security/findings.rb +++ b/spec/factories/ci/reports/security/findings.rb @@ -10,7 +10,7 @@ FactoryBot.define do metadata_version { 'sast:1.0' } name { 'Cipher with no integrity' } report_type { :sast } - cvss { [{ vendor: "GitLab", vector_string: "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N" }] } + cvss { [{ vendor: "GitLab", vector: "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N" }] } original_data do { description: "The cipher does not provide data integrity update 1", diff --git a/spec/factories/commit_statuses.rb b/spec/factories/commit_statuses.rb index 7d0176d0683..e0b34bc39d8 100644 --- a/spec/factories/commit_statuses.rb +++ b/spec/factories/commit_statuses.rb @@ -32,6 +32,10 @@ FactoryBot.define do status { 'running' } end + trait :waiting_for_callback do + status { 'waiting_for_callback' } + end + trait :pending do status { 'pending' } end diff --git a/spec/factories/ml/model_metadata.rb b/spec/factories/ml/model_metadata.rb new file mode 100644 index 00000000000..03ceaffa6bc --- /dev/null +++ b/spec/factories/ml/model_metadata.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :ml_model_metadata, class: '::Ml::ModelMetadata' do + association :model, factory: :ml_models + + sequence(:name) { |n| "metadata_#{n}" } + sequence(:value) { |n| "value#{n}" } + end +end diff --git a/spec/factories/ml/models.rb b/spec/factories/ml/models.rb index 158c26499b0..3377a54f265 100644 --- a/spec/factories/ml/models.rb +++ b/spec/factories/ml/models.rb @@ -18,5 +18,11 @@ FactoryBot.define do versions { [version] } latest_version { version } end + + trait :with_metadata do + after(:create) do |model| + model.metadata = FactoryBot.create_list(:ml_model_metadata, 2, model: model) # rubocop:disable StrategyInCallback + end + end end end diff --git a/spec/factories/packages/npm/metadata_cache.rb b/spec/factories/packages/npm/metadata_cache.rb index e76ddf3c983..4fe1930d03e 100644 --- a/spec/factories/packages/npm/metadata_cache.rb +++ b/spec/factories/packages/npm/metadata_cache.rb @@ -6,5 +6,15 @@ FactoryBot.define do sequence(:package_name) { |n| "@#{project.root_namespace.path}/package-#{n}" } file { fixture_file_upload('spec/fixtures/packages/npm/metadata.json') } size { 401.bytes } + + trait :processing do + status { 'processing' } + end + + trait :stale do + after(:create) do |entry| + entry.update_attribute(:project_id, nil) + end + end end end diff --git a/spec/factories/packages/nuget/symbol.rb b/spec/factories/packages/nuget/symbol.rb index 7ab1e026cda..665535de939 100644 --- a/spec/factories/packages/nuget/symbol.rb +++ b/spec/factories/packages/nuget/symbol.rb @@ -7,5 +7,6 @@ FactoryBot.define do file_path { 'lib/net7.0/package.pdb' } size { 100.bytes } sequence(:signature) { |n| "b91a152048fc4b3883bf3cf73fbc03f#{n}FFFFFFFF" } + file_sha256 { 'dd1aaf26c557685cc37f93f53a2b6befb2c2e679f5ace6ec7a26d12086f358be' } end end diff --git a/spec/factories/pages_domains.rb b/spec/factories/pages_domains.rb index d91037e803f..5b78c83251a 100644 --- a/spec/factories/pages_domains.rb +++ b/spec/factories/pages_domains.rb @@ -150,6 +150,87 @@ NVOFBkpdn627G190 end end + trait :with_untrusted_root_ca_in_chain do + # This contains + # [Intermediate #2 (SHA-2)] 'CloudFlare Origin SSL Certificate Authority' + # [Intermediate #1 (SHA-2)] 'C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QiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVIC +u9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+CGCe01a60y1Dma/RMhnEw6abf +Fobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5WdYgGq/yapiq +crxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E +FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB +/wQFMAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvl +wFTPoCWOAvn9sKIN9SCYPBMtrFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM +4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+nq6PK7o9mfjYcwlYRm6mnPTXJ9OV +2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSgtZx8jb8uk2Intzna +FxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwWsRqZ +CuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiK +boHGhfKppC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmcke +jkk9u+UJueBPSZI9FoJAzMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yL +S0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHqZJx64SIDqZxubw5lT2yHh17zbqD5daWb +QOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk527RH89elWsn2/x20Kk4yl +0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7ILaZRfyHB +NVOFBkpdn627G190 +-----END CERTIFICATE-----' + end + + key do + File.read(Rails.root.join('spec/fixtures/', 'origin_cert_key.pem')) + end + end + trait :with_trusted_expired_chain do # This contains # Let's Encrypt Authority X3 diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 443bca6030c..1e3ade779af 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -94,6 +94,8 @@ FactoryBot.define do visibility_level: evaluator.visibility_level } + project_namespace_hash[:id] = evaluator.project_namespace_id.presence + project.build_project_namespace(project_namespace_hash) project.build_project_feature(project_feature_hash) @@ -256,6 +258,35 @@ FactoryBot.define do end end + # A catalog resource repository with a file structure set up for ci components. + trait :catalog_resource_with_components do + small_repo + description { 'catalog resource' } + + files do + { + 'templates/secret-detection.yml' => "spec:\n inputs:\n website:\n---\nimage: alpine_1", + 'templates/dast/template.yml' => 'image: alpine_2', + 'templates/template.yml' => 'image: alpine_3', + 'templates/blank-yaml.yml' => '', + 'README.md' => 'readme' + } + end + + transient do + create_tag { nil } + end + + after(:create) do |project, evaluator| + if evaluator.create_tag + project.repository.add_tag( + project.creator, + evaluator.create_tag, + project.repository.commit.sha) + end + end + end + # A basic repository with a single file 'test.txt'. It also has the HEAD as the default branch. trait :small_repo do custom_repo @@ -477,7 +508,7 @@ FactoryBot.define do trait :pages_published do after(:create) do |project| project.mark_pages_onboarding_complete - project.mark_pages_as_deployed + create(:pages_deployment, project: project) # rubocop: disable RSpec/FactoryBot/StrategyInCallback end end diff --git a/spec/factories/snippet_repositories.rb b/spec/factories/snippet_repositories.rb index c3a6bc3ae31..1f9e68514bb 100644 --- a/spec/factories/snippet_repositories.rb +++ b/spec/factories/snippet_repositories.rb @@ -8,13 +8,5 @@ FactoryBot.define do snippet_repository.shard_name = snippet_repository.snippet.repository_storage snippet_repository.disk_path = snippet_repository.snippet.disk_path end - - trait(:checksummed) do - verification_checksum { 'abc' } - end - - trait(:checksum_failure) do - verification_failure { 'Could not calculate the checksum' } - end end end diff --git a/spec/factories/terraform/state_version.rb b/spec/factories/terraform/state_version.rb index c6bd08815cf..5386dfa98f2 100644 --- a/spec/factories/terraform/state_version.rb +++ b/spec/factories/terraform/state_version.rb @@ -8,13 +8,5 @@ FactoryBot.define do sequence(:version) file { fixture_file_upload('spec/fixtures/terraform/terraform.tfstate', 'application/json') } - - trait(:checksummed) do - verification_checksum { 'abc' } - end - - trait(:checksum_failure) do - verification_failure { 'Could not calculate the checksum' } - end end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index de2b5159fe7..8b42631040e 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -135,10 +135,6 @@ FactoryBot.define do end end - trait :no_super_sidebar do - use_new_navigation { false } - end - trait :two_factor_via_webauthn do transient { registrations_count { 5 } } diff --git a/spec/factories/users/phone_number_validations.rb b/spec/factories/users/phone_number_validations.rb index da53dda89b4..b7e6e819127 100644 --- a/spec/factories/users/phone_number_validations.rb +++ b/spec/factories/users/phone_number_validations.rb @@ -6,5 +6,6 @@ FactoryBot.define do country { 'US' } international_dial_code { 1 } phone_number { '555' } + telesign_reference_xid { FFaker::Guid.guid } end end |