diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 09:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-03 09:09:14 +0300 |
commit | 42f41de46525ce0065f02ee07c1a79f5669526a0 (patch) | |
tree | 6e8151aae2628d2c2ce8942be1ba547afe0264b2 /spec | |
parent | 1eeef229aae5affdce415c2364858e8efc64f4b5 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/pipelines_controller_spec.rb | 35 | ||||
-rw-r--r-- | spec/factories/ci/builds.rb | 6 | ||||
-rw-r--r-- | spec/factories/ci/job_artifacts.rb | 10 | ||||
-rw-r--r-- | spec/factories/ci/pipelines.rb | 8 | ||||
-rw-r--r-- | spec/fixtures/junit/junit_with_attachment.xml.gz | bin | 0 -> 929 bytes | |||
-rw-r--r-- | spec/lib/gitlab/auth/ldap/config_spec.rb | 14 |
6 files changed, 69 insertions, 4 deletions
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb index 0368130118f..d9345cfaced 100644 --- a/spec/controllers/projects/pipelines_controller_spec.rb +++ b/spec/controllers/projects/pipelines_controller_spec.rb @@ -788,6 +788,28 @@ describe Projects::PipelinesController do expect(json_response['status']).to eq('error_parsing_report') end end + + context 'when test_report contains attachment and scope is with_attachment as a URL param' do + let(:pipeline) { create(:ci_pipeline, :with_test_reports_attachment, project: project) } + + it 'returns a test reports with attachment' do + get_test_report_json(scope: 'with_attachment') + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response["test_suites"]).to be_present + end + end + + context 'when test_report does not contain attachment and scope is with_attachment as a URL param' do + let(:pipeline) { create(:ci_pipeline, :with_test_reports, project: project) } + + it 'returns a test reports with empty values' do + get_test_report_json(scope: 'with_attachment') + + expect(response).to have_gitlab_http_status(:ok) + expect(json_response["test_suites"]).to be_empty + end + end end context 'when feature is disabled' do @@ -805,13 +827,18 @@ describe Projects::PipelinesController do end end - def get_test_report_json - get :test_report, params: { + def get_test_report_json(**args) + params = { namespace_id: project.namespace, project_id: project, id: pipeline.id - }, - format: :json + } + + params.merge!(args) if args + + get :test_report, + params: params, + format: :json end def clear_controller_memoization diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 5bb7853a154..ccaf0dd997b 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -311,6 +311,12 @@ FactoryBot.define do end end + trait :test_reports_with_attachment do + after(:build) do |build| + build.job_artifacts << create(:ci_job_artifact, :junit_with_attachment, job: build) + end + end + trait :coverage_reports do after(:build) do |build| build.job_artifacts << create(:ci_job_artifact, :cobertura, job: build) diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb index 8fbf242a607..82383cfa2b0 100644 --- a/spec/factories/ci/job_artifacts.rb +++ b/spec/factories/ci/job_artifacts.rb @@ -99,6 +99,16 @@ FactoryBot.define do end end + 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 + trait :junit_with_ant do file_type { :junit } file_format { :gzip } diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb index f2c342f76d0..e0478097148 100644 --- a/spec/factories/ci/pipelines.rb +++ b/spec/factories/ci/pipelines.rb @@ -67,6 +67,14 @@ FactoryBot.define do end end + trait :with_test_reports_attachment do + status { :success } + + after(:build) do |pipeline, evaluator| + pipeline.builds << build(:ci_build, :test_reports_with_attachment, pipeline: pipeline, project: pipeline.project) + end + end + trait :with_coverage_reports do status { :success } diff --git a/spec/fixtures/junit/junit_with_attachment.xml.gz b/spec/fixtures/junit/junit_with_attachment.xml.gz Binary files differnew file mode 100644 index 00000000000..75a92fada2c --- /dev/null +++ b/spec/fixtures/junit/junit_with_attachment.xml.gz diff --git a/spec/lib/gitlab/auth/ldap/config_spec.rb b/spec/lib/gitlab/auth/ldap/config_spec.rb index 0967c45d36b..124f072ebe6 100644 --- a/spec/lib/gitlab/auth/ldap/config_spec.rb +++ b/spec/lib/gitlab/auth/ldap/config_spec.rb @@ -502,6 +502,20 @@ AtlErSqafbECNDSwS5BX8yDpu5yRBJ4xegO/rNlmb8ICRYkuJapD1xXicFOsmfUK end end + describe '#default_attributes' do + it 'includes the configured uid attribute in the username attributes' do + stub_ldap_config(options: { 'uid' => 'my_uid_attr' }) + + expect(config.default_attributes['username']).to include('my_uid_attr') + end + + it 'only includes unique values for username attributes' do + stub_ldap_config(options: { 'uid' => 'uid' }) + + expect(config.default_attributes['username']).to contain_exactly('uid', 'sAMAccountName', 'userid') + end + end + describe '#base' do context 'when the configured base is not normalized' do it 'returns the normalized base' do |