debian-mirror-gitlab/spec/factories/integrations.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

272 lines
7.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
FactoryBot.define do
2022-03-02 08:16:31 +05:30
factory :integration do
2017-09-10 17:25:29 +05:30
project
2021-06-08 01:23:25 +05:30
type { 'Integration' }
2017-08-17 22:00:37 +05:30
end
2021-09-04 01:27:46 +05:30
factory :custom_issue_tracker_integration, class: 'Integrations::CustomIssueTracker' do
2017-09-10 17:25:29 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
2019-12-04 20:38:33 +05:30
issue_tracker
2017-08-17 22:00:37 +05:30
end
2022-05-07 20:08:51 +05:30
factory :jenkins_integration, class: 'Integrations::Jenkins' do
project
active { true }
type { 'Integrations::Jenkins' }
jenkins_url { 'http://jenkins.example.com/' }
project_name { 'my-project' }
username { 'jenkings-user' }
password { 'passw0rd' }
end
2021-11-11 11:23:49 +05:30
factory :datadog_integration, class: 'Integrations::Datadog' do
project
active { true }
api_key { 'secret' }
end
2021-09-04 01:27:46 +05:30
factory :emails_on_push_integration, class: 'Integrations::EmailsOnPush' do
2017-09-10 17:25:29 +05:30
project
2022-05-07 20:08:51 +05:30
type { 'Integrations::EmailsOnPush' }
2019-12-21 20:55:43 +05:30
active { true }
push_events { true }
tag_push_events { true }
properties do
{
recipients: 'test@example.com',
disable_diffs: true,
send_from_committer_email: true
}
end
2017-09-10 17:25:29 +05:30
end
2021-09-30 23:02:18 +05:30
factory :prometheus_integration, class: 'Integrations::Prometheus' do
2017-09-10 17:25:29 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
properties do
{
api_url: 'https://prometheus.example.com/',
manual_configuration: true
}
end
2017-08-17 22:00:37 +05:30
end
2021-09-04 01:27:46 +05:30
factory :drone_ci_integration, class: 'Integrations::DroneCi' do
2020-01-01 13:55:28 +05:30
project
active { true }
drone_url { 'https://bamboo.example.com' }
token { 'test' }
end
2021-09-30 23:02:18 +05:30
factory :jira_integration, class: 'Integrations::Jira' do
2017-09-10 17:25:29 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
2022-05-07 20:08:51 +05:30
type { 'Integrations::Jira' }
2019-12-04 20:38:33 +05:30
transient do
2019-12-21 20:55:43 +05:30
create_data { true }
url { 'https://jira.example.com' }
2021-10-27 15:23:28 +05:30
api_url { '' }
2019-12-21 20:55:43 +05:30
username { 'jira_username' }
password { 'jira_password' }
2021-04-29 21:17:54 +05:30
jira_issue_transition_automatic { false }
2019-12-21 20:55:43 +05:30
jira_issue_transition_id { '56-1' }
2020-07-28 23:09:34 +05:30
issues_enabled { false }
project_key { nil }
2021-01-29 00:20:46 +05:30
vulnerabilities_enabled { false }
vulnerabilities_issuetype { nil }
2021-04-29 21:17:54 +05:30
deployment_type { 'cloud' }
2019-12-04 20:38:33 +05:30
end
2021-06-08 01:23:25 +05:30
after(:build) do |integration, evaluator|
2019-12-04 20:38:33 +05:30
if evaluator.create_data
2021-06-08 01:23:25 +05:30
integration.jira_tracker_data = build(:jira_tracker_data,
integration: integration, url: evaluator.url, api_url: evaluator.api_url,
jira_issue_transition_automatic: evaluator.jira_issue_transition_automatic,
jira_issue_transition_id: evaluator.jira_issue_transition_id,
username: evaluator.username, password: evaluator.password, issues_enabled: evaluator.issues_enabled,
project_key: evaluator.project_key, vulnerabilities_enabled: evaluator.vulnerabilities_enabled,
vulnerabilities_issuetype: evaluator.vulnerabilities_issuetype, deployment_type: evaluator.deployment_type
2019-12-04 20:38:33 +05:30
)
end
end
2016-06-02 11:05:42 +05:30
end
2017-09-10 17:25:29 +05:30
2021-11-11 11:23:49 +05:30
factory :zentao_integration, class: 'Integrations::Zentao' do
project
active { true }
2022-05-07 20:08:51 +05:30
type { 'Integrations::Zentao' }
2021-11-11 11:23:49 +05:30
transient do
create_data { true }
url { 'https://jihudemo.zentao.net' }
api_url { '' }
api_token { 'ZENTAO_TOKEN' }
zentao_product_xid { '3' }
end
after(:build) do |integration, evaluator|
if evaluator.create_data
integration.zentao_tracker_data = build(:zentao_tracker_data,
integration: integration,
url: evaluator.url,
api_url: evaluator.api_url,
api_token: evaluator.api_token,
zentao_product_xid: evaluator.zentao_product_xid
)
end
end
end
2021-12-11 22:18:48 +05:30
factory :shimo_integration, class: 'Integrations::Shimo' do
project
active { true }
external_wiki_url { 'https://shimo.example.com/desktop' }
end
2021-09-04 01:27:46 +05:30
factory :confluence_integration, class: 'Integrations::Confluence' do
2020-07-28 23:09:34 +05:30
project
active { true }
confluence_url { 'https://example.atlassian.net/wiki' }
end
2021-09-04 01:27:46 +05:30
factory :bugzilla_integration, class: 'Integrations::Bugzilla' do
2018-12-13 13:39:08 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
2019-09-30 21:07:59 +05:30
issue_tracker
end
2021-09-30 23:02:18 +05:30
factory :redmine_integration, class: 'Integrations::Redmine' do
2019-09-30 21:07:59 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
2019-09-30 21:07:59 +05:30
issue_tracker
end
2021-09-30 23:02:18 +05:30
factory :youtrack_integration, class: 'Integrations::Youtrack' do
2019-09-30 21:07:59 +05:30
project
2019-12-21 20:55:43 +05:30
active { true }
2019-09-30 21:07:59 +05:30
issue_tracker
end
2021-09-04 01:27:46 +05:30
factory :ewm_integration, class: 'Integrations::Ewm' do
2020-11-24 15:15:51 +05:30
project
active { true }
issue_tracker
end
2019-09-30 21:07:59 +05:30
trait :issue_tracker do
2019-12-04 20:38:33 +05:30
transient do
2019-12-21 20:55:43 +05:30
create_data { true }
project_url { 'http://issuetracker.example.com' }
issues_url { 'http://issues.example.com/issues/:id' }
new_issue_url { 'http://new-issue.example.com' }
2019-12-04 20:38:33 +05:30
end
2021-06-08 01:23:25 +05:30
after(:build) do |integration, evaluator|
2019-12-04 20:38:33 +05:30
if evaluator.create_data
2021-06-08 01:23:25 +05:30
integration.issue_tracker_data = build(:issue_tracker_data,
integration: integration, project_url: evaluator.project_url,
issues_url: evaluator.issues_url, new_issue_url: evaluator.new_issue_url
2019-12-04 20:38:33 +05:30
)
end
end
2019-09-30 21:07:59 +05:30
end
2021-09-04 01:27:46 +05:30
factory :external_wiki_integration, class: 'Integrations::ExternalWiki' do
2021-01-29 00:20:46 +05:30
project
2022-05-07 20:08:51 +05:30
type { 'Integrations::ExternalWiki' }
2021-01-29 00:20:46 +05:30
active { true }
external_wiki_url { 'http://external-wiki-url.com' }
end
2019-09-30 21:07:59 +05:30
trait :jira_cloud_service do
2019-12-21 20:55:43 +05:30
url { 'https://mysite.atlassian.net' }
username { 'jira_user' }
password { 'my-secret-password' }
2018-12-13 13:39:08 +05:30
end
2022-05-07 20:08:51 +05:30
trait :chat_notification do
2022-06-21 17:19:12 +05:30
sequence(:webhook) { |n| "https://example.com/webhook/#{n}" }
2022-05-07 20:08:51 +05:30
end
trait :inactive do
active { false }
end
factory :mattermost_integration, class: 'Integrations::Mattermost' do
chat_notification
project
type { 'Integrations::Mattermost' }
active { true }
end
2021-09-30 23:02:18 +05:30
# avoids conflict with slack_integration factory
factory :integrations_slack, class: 'Integrations::Slack' do
2022-05-07 20:08:51 +05:30
chat_notification
2020-05-24 23:13:21 +05:30
project
active { true }
2022-05-07 20:08:51 +05:30
type { 'Integrations::Slack' }
2020-05-24 23:13:21 +05:30
end
2021-09-30 23:02:18 +05:30
factory :slack_slash_commands_integration, class: 'Integrations::SlackSlashCommands' do
2021-09-04 01:27:46 +05:30
project
active { true }
2022-05-07 20:08:51 +05:30
type { 'Integrations::SlackSlashCommands' }
2021-09-04 01:27:46 +05:30
end
2021-09-30 23:02:18 +05:30
factory :pipelines_email_integration, class: 'Integrations::PipelinesEmail' do
2020-06-23 00:09:42 +05:30
project
active { true }
2022-05-07 20:08:51 +05:30
type { 'Integrations::PipelinesEmail' }
2020-06-23 00:09:42 +05:30
recipients { 'test@example.com' }
end
2022-05-07 20:08:51 +05:30
factory :pivotaltracker_integration, class: 'Integrations::Pivotaltracker' do
project
active { true }
token { 'test' }
end
factory :harbor_integration, class: 'Integrations::Harbor' do
project
active { true }
type { 'HarborService' }
url { 'https://demo.goharbor.io' }
project_name { 'testproject' }
username { 'harborusername' }
password { 'harborpassword' }
end
2019-12-04 20:38:33 +05:30
# this is for testing storing values inside properties, which is deprecated and will be removed in
2019-12-21 20:55:43 +05:30
# https://gitlab.com/gitlab-org/gitlab/issues/29404
2019-09-30 21:07:59 +05:30
trait :without_properties_callback do
2019-12-21 20:55:43 +05:30
jira_tracker_data { nil }
issue_tracker_data { nil }
create_data { false }
2019-12-04 20:38:33 +05:30
2021-06-08 01:23:25 +05:30
after(:build) do
2021-09-04 01:27:46 +05:30
Integrations::BaseIssueTracker.skip_callback(:validation, :before, :handle_properties)
2019-09-30 21:07:59 +05:30
end
2020-10-24 23:57:45 +05:30
to_create { |instance| instance.save!(validate: false) }
2019-12-04 20:38:33 +05:30
after(:create) do
2021-09-04 01:27:46 +05:30
Integrations::BaseIssueTracker.set_callback(:validation, :before, :handle_properties)
2019-09-30 21:07:59 +05:30
end
end
2020-04-08 14:13:33 +05:30
2021-12-11 22:18:48 +05:30
trait :group do
group
project { nil }
end
2020-04-08 14:13:33 +05:30
trait :instance do
project { nil }
instance { true }
end
2016-06-02 11:05:42 +05:30
end