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
path: root/spec/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 03:07:31 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-12-24 03:07:31 +0300
commit3888bc4261500c275759683076e07baaf352e5ec (patch)
treeeb70e0415be41a1d713cc89f211a6045778cd6b8 /spec/lib
parent33e1622bfe5afb2eea08ff06e44de490383a93e3 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb95
-rw-r--r--spec/lib/gitlab/import_export/all_models.yml1
-rw-r--r--spec/lib/gitlab/kubernetes/kube_client_spec.rb37
3 files changed, 102 insertions, 31 deletions
diff --git a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
index f84f10bdc46..aaea044595f 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/config/content_spec.rb
@@ -29,6 +29,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'repository_source'
+ expect(pipeline.pipeline_config).to be_nil
expect(command.config_content).to eq('the-content')
end
end
@@ -40,6 +41,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'auto_devops_source'
+ expect(pipeline.pipeline_config).to be_nil
template = Gitlab::Template::GitlabCiYmlTemplate.find('Beta/Auto-DevOps')
expect(command.config_content).to eq(template.content)
end
@@ -52,6 +54,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'auto_devops_source'
+ expect(pipeline.pipeline_config).to be_nil
template = Gitlab::Template::GitlabCiYmlTemplate.find('Beta/Auto-DevOps')
expect(command.config_content).to eq(template.content)
end
@@ -71,6 +74,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'repository_source'
+ expect(pipeline.pipeline_config).to be_nil
expect(command.config_content).to eq('the-content')
end
end
@@ -91,6 +95,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'auto_devops_source'
+ expect(pipeline.pipeline_config).to be_nil
template = Gitlab::Template::GitlabCiYmlTemplate.find('Beta/Auto-DevOps')
expect(command.config_content).to eq(template.content)
end
@@ -105,6 +110,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'auto_devops_source'
+ expect(pipeline.pipeline_config).to be_nil
template = Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps')
expect(command.config_content).to eq(template.content)
end
@@ -122,6 +128,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq('unknown_source')
+ expect(pipeline.pipeline_config).to be_nil
expect(command.config_content).to be_nil
expect(pipeline.errors.full_messages).to include('Missing CI config file')
end
@@ -130,6 +137,13 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
context 'when config is defined in a custom path in the repository' do
let(:ci_config_path) { 'path/to/config.yml' }
+ let(:config_content_result) do
+ <<~EOY
+ ---
+ include:
+ - local: #{ci_config_path}
+ EOY
+ end
before do
expect(project.repository)
@@ -142,47 +156,59 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'repository_source'
- expect(command.config_content).to eq(<<~EOY)
- ---
- include:
- - local: #{ci_config_path}
- EOY
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
end
end
context 'when config is defined remotely' do
let(:ci_config_path) { 'http://example.com/path/to/ci/config.yml' }
+ let(:config_content_result) do
+ <<~EOY
+ ---
+ include:
+ - remote: #{ci_config_path}
+ EOY
+ end
it 'builds root config including the remote config' do
subject.perform!
expect(pipeline.config_source).to eq 'remote_source'
- expect(command.config_content).to eq(<<~EOY)
- ---
- include:
- - remote: #{ci_config_path}
- EOY
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
end
end
context 'when config is defined in a separate repository' do
let(:ci_config_path) { 'path/to/.gitlab-ci.yml@another-group/another-repo' }
-
- it 'builds root config including the path to another repository' do
- subject.perform!
-
- expect(pipeline.config_source).to eq 'external_project_source'
- expect(command.config_content).to eq(<<~EOY)
+ let(:config_content_result) do
+ <<~EOY
---
include:
- project: another-group/another-repo
file: path/to/.gitlab-ci.yml
EOY
end
+
+ it 'builds root config including the path to another repository' do
+ subject.perform!
+
+ expect(pipeline.config_source).to eq 'external_project_source'
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
+ end
end
context 'when config is defined in the default .gitlab-ci.yml' do
let(:ci_config_path) { nil }
+ let(:config_content_result) do
+ <<~EOY
+ ---
+ include:
+ - local: ".gitlab-ci.yml"
+ EOY
+ end
before do
expect(project.repository)
@@ -195,16 +221,20 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'repository_source'
- expect(command.config_content).to eq(<<~EOY)
- ---
- include:
- - local: ".gitlab-ci.yml"
- EOY
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
end
end
context 'when config is the Auto-Devops template' do
let(:ci_config_path) { nil }
+ let(:config_content_result) do
+ <<~EOY
+ ---
+ include:
+ - template: Beta/Auto-DevOps.gitlab-ci.yml
+ EOY
+ end
before do
expect(project).to receive(:auto_devops_enabled?).and_return(true)
@@ -219,11 +249,8 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq 'auto_devops_source'
- expect(command.config_content).to eq(<<~EOY)
- ---
- include:
- - template: Beta/Auto-DevOps.gitlab-ci.yml
- EOY
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
end
end
@@ -232,16 +259,21 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
stub_feature_flags(auto_devops_beta: false)
end
- it 'builds root config including the auto-devops template' do
- subject.perform!
-
- expect(pipeline.config_source).to eq 'auto_devops_source'
- expect(command.config_content).to eq(<<~EOY)
+ let(:config_content_result) do
+ <<~EOY
---
include:
- template: Auto-DevOps.gitlab-ci.yml
EOY
end
+
+ it 'builds root config including the auto-devops template' do
+ subject.perform!
+
+ expect(pipeline.config_source).to eq 'auto_devops_source'
+ expect(pipeline.pipeline_config.content).to eq(config_content_result)
+ expect(command.config_content).to eq(config_content_result)
+ end
end
end
@@ -256,6 +288,7 @@ describe Gitlab::Ci::Pipeline::Chain::Config::Content do
subject.perform!
expect(pipeline.config_source).to eq('unknown_source')
+ expect(pipeline.pipeline_config).to be_nil
expect(command.config_content).to be_nil
expect(pipeline.errors.full_messages).to include('Missing CI config file')
end
diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml
index 8f0f09bc0be..a625d2f6cce 100644
--- a/spec/lib/gitlab/import_export/all_models.yml
+++ b/spec/lib/gitlab/import_export/all_models.yml
@@ -190,6 +190,7 @@ ci_pipelines:
- job_artifacts
- vulnerabilities_occurrence_pipelines
- vulnerability_findings
+- pipeline_config
pipeline_variables:
- pipeline
stages:
diff --git a/spec/lib/gitlab/kubernetes/kube_client_spec.rb b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
index 59e81d89a50..e08981a3415 100644
--- a/spec/lib/gitlab/kubernetes/kube_client_spec.rb
+++ b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
@@ -136,6 +136,20 @@ describe Gitlab::Kubernetes::KubeClient do
end
end
+ describe '#istio_client' do
+ subject { client.istio_client }
+
+ it_behaves_like 'a Kubeclient'
+
+ it 'has the Istio API group endpoint' do
+ expect(subject.api_endpoint.to_s).to match(%r{\/apis\/networking.istio.io\Z})
+ end
+
+ it 'has the api_version' do
+ expect(subject.instance_variable_get(:@api_version)).to eq('v1alpha3')
+ end
+ end
+
describe '#knative_client' do
subject { client.knative_client }
@@ -233,6 +247,29 @@ describe Gitlab::Kubernetes::KubeClient do
end
end
+ describe 'istio API group' do
+ let(:istio_client) { client.istio_client }
+
+ [
+ :create_gateway,
+ :get_gateway,
+ :update_gateway
+ ].each do |method|
+ describe "##{method}" do
+ include_examples 'redirection not allowed', method
+ include_examples 'dns rebinding not allowed', method
+
+ it 'delegates to the istio client' do
+ expect(client).to delegate_method(method).to(:istio_client)
+ end
+
+ it 'responds to the method' do
+ expect(client).to respond_to method
+ end
+ end
+ end
+ end
+
describe 'non-entity methods' do
it 'does not proxy for non-entity methods' do
expect(client).not_to respond_to :proxy_url