summaryrefslogtreecommitdiff
path: root/spec/models/integrations
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 19:01:26 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-27 19:01:26 +0000
commit1ff28a8d8d370efef8bbac2da1edb85b758d4643 (patch)
tree906de1dd9c7637330f2eaea9c1a4217decd9a749 /spec/models/integrations
parenta876afc5fd85a4ccae6947941884f3913f472ab0 (diff)
downloadgitlab-ce-1ff28a8d8d370efef8bbac2da1edb85b758d4643.tar.gz
Add latest changes from gitlab-org/security/gitlab@15-2-stable-ee
Diffstat (limited to 'spec/models/integrations')
-rw-r--r--spec/models/integrations/campfire_spec.rb10
-rw-r--r--spec/models/integrations/drone_ci_spec.rb4
-rw-r--r--spec/models/integrations/jira_spec.rb20
-rw-r--r--spec/models/integrations/packagist_spec.rb4
-rw-r--r--spec/models/integrations/zentao_spec.rb25
5 files changed, 62 insertions, 1 deletions
diff --git a/spec/models/integrations/campfire_spec.rb b/spec/models/integrations/campfire_spec.rb
index 405a9ff4b3f..48e24299bbd 100644
--- a/spec/models/integrations/campfire_spec.rb
+++ b/spec/models/integrations/campfire_spec.rb
@@ -5,7 +5,17 @@ require 'spec_helper'
RSpec.describe Integrations::Campfire do
include StubRequests
+ it_behaves_like Integrations::ResetSecretFields do
+ let(:integration) { described_class.new }
+ end
+
describe 'Validations' do
+ it { is_expected.to validate_numericality_of(:room).is_greater_than(0).only_integer }
+ it { is_expected.to validate_length_of(:subdomain).is_at_most(63) }
+ it { is_expected.to allow_value("foo").for(:subdomain) }
+ it { is_expected.not_to allow_value("foo.bar").for(:subdomain) }
+ it { is_expected.not_to allow_value("foo.bar/#").for(:subdomain) }
+
context 'when integration is active' do
before do
subject.active = true
diff --git a/spec/models/integrations/drone_ci_spec.rb b/spec/models/integrations/drone_ci_spec.rb
index 78d55c49e7b..5ae4af1a665 100644
--- a/spec/models/integrations/drone_ci_spec.rb
+++ b/spec/models/integrations/drone_ci_spec.rb
@@ -7,6 +7,10 @@ RSpec.describe Integrations::DroneCi, :use_clean_rails_memory_store_caching do
subject(:integration) { described_class.new }
+ it_behaves_like Integrations::ResetSecretFields do
+ let(:integration) { subject }
+ end
+
describe 'validations' do
context 'active' do
before do
diff --git a/spec/models/integrations/jira_spec.rb b/spec/models/integrations/jira_spec.rb
index 2a994540bd3..01c08a0948f 100644
--- a/spec/models/integrations/jira_spec.rb
+++ b/spec/models/integrations/jira_spec.rb
@@ -12,6 +12,7 @@ RSpec.describe Integrations::Jira do
let(:api_url) { 'http://api-jira.example.com' }
let(:username) { 'jira-username' }
let(:password) { 'jira-password' }
+ let(:project_key) { nil }
let(:transition_id) { 'test27' }
let(:server_info_results) { { 'deploymentType' => 'Cloud' } }
let(:jira_integration) do
@@ -19,7 +20,8 @@ RSpec.describe Integrations::Jira do
project: project,
url: url,
username: username,
- password: password
+ password: password,
+ project_key: project_key
)
end
@@ -533,6 +535,22 @@ RSpec.describe Integrations::Jira do
expect(WebMock).to have_requested(:get, issue_url)
end
end
+
+ context 'with restricted restrict_project_key option' do
+ subject(:find_issue) { jira_integration.find_issue(issue_key, restrict_project_key: true) }
+
+ it { is_expected.to eq(nil) }
+
+ context 'and project_key matches' do
+ let(:project_key) { 'JIRA' }
+
+ it 'calls the Jira API to get the issue' do
+ find_issue
+
+ expect(WebMock).to have_requested(:get, issue_url)
+ end
+ end
+ end
end
describe '#close_issue' do
diff --git a/spec/models/integrations/packagist_spec.rb b/spec/models/integrations/packagist_spec.rb
index dce96890522..d1976e73e2e 100644
--- a/spec/models/integrations/packagist_spec.rb
+++ b/spec/models/integrations/packagist_spec.rb
@@ -29,6 +29,10 @@ RSpec.describe Integrations::Packagist do
let(:hook_url) { "#{packagist_server}/api/update-package?username=#{packagist_username}&apiToken=#{packagist_token}" }
end
+ it_behaves_like Integrations::ResetSecretFields do
+ let(:integration) { described_class.new(packagist_params) }
+ end
+
describe '#execute' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
diff --git a/spec/models/integrations/zentao_spec.rb b/spec/models/integrations/zentao_spec.rb
index 2b0532c7930..4ef977ba3d2 100644
--- a/spec/models/integrations/zentao_spec.rb
+++ b/spec/models/integrations/zentao_spec.rb
@@ -9,6 +9,31 @@ RSpec.describe Integrations::Zentao do
let(:zentao_product_xid) { '3' }
let(:zentao_integration) { create(:zentao_integration) }
+ it_behaves_like Integrations::ResetSecretFields do
+ let(:integration) { zentao_integration }
+ end
+
+ describe 'set_default_data' do
+ let(:project) { create(:project, :repository) }
+
+ context 'when gitlab.yml was initialized' do
+ it 'is prepopulated with the settings' do
+ settings = {
+ 'zentao' => {
+ 'url' => 'http://zentao.sample/projects/project_a',
+ 'api_url' => 'http://zentao.sample/api'
+ }
+ }
+ allow(Gitlab.config).to receive(:issues_tracker).and_return(settings)
+
+ integration = project.create_zentao_integration(active: true)
+
+ expect(integration.url).to eq('http://zentao.sample/projects/project_a')
+ expect(integration.api_url).to eq('http://zentao.sample/api')
+ end
+ end
+ end
+
describe '#create' do
let(:project) { create(:project, :repository) }
let(:params) do