Commit 9abc9fe0 authored by Sean McGivern's avatar Sean McGivern

Merge branch '26574-rename-pipeline-method' into 'master'

Rename license management in pipeline and build

See merge request gitlab-org/gitlab!18124
parents 0022b6b2 f2c902d3
...@@ -25,13 +25,13 @@ module EE ...@@ -25,13 +25,13 @@ module EE
end end
def licenses def licenses
report_exists = pipeline.expose_license_management_data? report_exists = pipeline.expose_license_scanning_data?
respond_to do |format| respond_to do |format|
if report_exists if report_exists
format.html { render_show } format.html { render_show }
format.json do format.json do
data = LicenseManagementReportsSerializer.new(project: project, current_user: current_user).represent(pipeline&.license_management_report&.licenses) data = LicenseManagementReportsSerializer.new(project: project, current_user: current_user).represent(pipeline&.license_scanning_report&.licenses)
render json: data, status: :ok render json: data, status: :ok
end end
else else
......
...@@ -135,7 +135,7 @@ class ApprovalMergeRequestRule < ApplicationRecord ...@@ -135,7 +135,7 @@ class ApprovalMergeRequestRule < ApplicationRecord
end end
def refresh_license_management_approvals(project_approval_rule) def refresh_license_management_approvals(project_approval_rule)
license_report = merge_request.head_pipeline&.license_management_report license_report = merge_request.head_pipeline&.license_scanning_report
return if license_report.blank? return if license_report.blank?
if license_report.violates?(project.software_license_policies) if license_report.violates?(project.software_license_policies)
......
...@@ -61,16 +61,16 @@ module EE ...@@ -61,16 +61,16 @@ module EE
end end
end end
def collect_license_management_reports!(license_management_report) def collect_license_scanning_reports!(license_scanning_report)
each_report(::Ci::JobArtifact::LICENSE_MANAGEMENT_REPORT_FILE_TYPES) do |file_type, blob| each_report(::Ci::JobArtifact::LICENSE_MANAGEMENT_REPORT_FILE_TYPES) do |file_type, blob|
next if ::Feature.disabled?(:parse_license_management_reports, default_enabled: true) next if ::Feature.disabled?(:parse_license_management_reports, default_enabled: true)
next unless project.feature_available?(:license_management) next unless project.feature_available?(:license_management)
::Gitlab::Ci::Parsers.fabricate!(file_type).parse!(blob, license_management_report) ::Gitlab::Ci::Parsers.fabricate!(file_type).parse!(blob, license_scanning_report)
end end
license_management_report license_scanning_report
end end
def collect_dependency_list_reports!(dependency_list_report) def collect_dependency_list_reports!(dependency_list_report)
......
...@@ -121,7 +121,7 @@ module EE ...@@ -121,7 +121,7 @@ module EE
job_artifacts.where(file_type: ::Ci::JobArtifact.file_types[file_type]).last job_artifacts.where(file_type: ::Ci::JobArtifact.file_types[file_type]).last
end end
def expose_license_management_data? def expose_license_scanning_data?
any_report_artifact_for_type(:license_management) any_report_artifact_for_type(:license_management)
end end
...@@ -133,10 +133,10 @@ module EE ...@@ -133,10 +133,10 @@ module EE
end end
end end
def license_management_report def license_scanning_report
::Gitlab::Ci::Reports::LicenseScanning::Report.new.tap do |license_management_report| ::Gitlab::Ci::Reports::LicenseScanning::Report.new.tap do |license_management_report|
builds.latest.with_reports(::Ci::JobArtifact.license_management_reports).each do |build| builds.latest.with_reports(::Ci::JobArtifact.license_management_reports).each do |build|
build.collect_license_management_reports!(license_management_report) build.collect_license_scanning_reports!(license_management_report)
end end
end end
end end
......
...@@ -11,7 +11,7 @@ module Ci ...@@ -11,7 +11,7 @@ module Ci
end end
def get_report(pipeline) def get_report(pipeline)
pipeline&.license_management_report pipeline&.license_scanning_report
end end
end end
end end
...@@ -8,7 +8,7 @@ module Security ...@@ -8,7 +8,7 @@ module Security
end end
def execute def execute
pipeline.license_management_report.licenses pipeline.license_scanning_report.licenses
end end
private private
......
...@@ -29,7 +29,7 @@ module Security ...@@ -29,7 +29,7 @@ module Security
def sync_license_management_rules def sync_license_management_rules
project = pipeline.project project = pipeline.project
report = pipeline.license_management_report report = pipeline.license_scanning_report
return if report.empty? && !pipeline.complete? return if report.empty? && !pipeline.complete?
return if report.violates?(project.software_license_policies) return if report.violates?(project.software_license_policies)
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
create_vulnerability_feedback_merge_request_path: create_vulnerability_feedback_merge_request_path(project), create_vulnerability_feedback_merge_request_path: create_vulnerability_feedback_merge_request_path(project),
create_vulnerability_feedback_dismissal_path: create_vulnerability_feedback_dismissal_path(project) } } create_vulnerability_feedback_dismissal_path: create_vulnerability_feedback_dismissal_path(project) } }
- if pipeline.expose_license_management_data? - if pipeline.expose_license_scanning_data?
#js-tab-licenses.tab-pane #js-tab-licenses.tab-pane
#js-licenses-app{ data: { license_head_path: pipeline.downloadable_path_for_report_type(:license_management), #js-licenses-app{ data: { license_head_path: pipeline.downloadable_path_for_report_type(:license_management),
api_url: license_management_api_url(project), api_url: license_management_api_url(project),
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= _("Security") = _("Security")
%span.badge.badge-pill.js-security-counter.hidden{ 'data-qa-selector': 'security_counter' } %span.badge.badge-pill.js-security-counter.hidden{ 'data-qa-selector': 'security_counter' }
- if pipeline.expose_license_management_data? - if pipeline.expose_license_scanning_data?
%li.js-licenses-tab-link %li.js-licenses-tab-link
= link_to licenses_project_pipeline_path(project, pipeline), data: { target: '#js-tab-licenses', action: 'licenses', toggle: 'tab' }, class: 'licenses-tab' do = link_to licenses_project_pipeline_path(project, pipeline), data: { target: '#js-tab-licenses', action: 'licenses', toggle: 'tab' }, class: 'licenses-tab' do
= _("Licenses") = _("Licenses")
......
...@@ -285,13 +285,13 @@ describe Projects::PipelinesController do ...@@ -285,13 +285,13 @@ describe Projects::PipelinesController do
end end
it 'will return license management report in json format' do it 'will return license management report in json format' do
expect(payload.size).to eq(pipeline.license_management_report.licenses.size) expect(payload.size).to eq(pipeline.license_scanning_report.licenses.size)
expect(payload.first.keys).to eq(%w(name classification dependencies count url)) expect(payload.first.keys).to eq(%w(name classification dependencies count url))
end end
it 'will return mit license approved status' do it 'will return mit license approved status' do
payload_mit = payload.find { |l| l['name'] == 'MIT' } payload_mit = payload.find { |l| l['name'] == 'MIT' }
expect(payload_mit['count']).to eq(pipeline.license_management_report.found_licenses['MIT'].count) expect(payload_mit['count']).to eq(pipeline.license_scanning_report.found_licenses['MIT'].count)
expect(payload_mit['url']).to eq('http://opensource.org/licenses/mit-license') expect(payload_mit['url']).to eq('http://opensource.org/licenses/mit-license')
expect(payload_mit['classification']['approval_status']).to eq('approved') expect(payload_mit['classification']['approval_status']).to eq('approved')
end end
......
...@@ -321,7 +321,7 @@ describe ApprovalMergeRequestRule do ...@@ -321,7 +321,7 @@ describe ApprovalMergeRequestRule do
context "when the latest license report violates the compliance policy" do context "when the latest license report violates the compliance policy" do
let(:license) { create(:software_license, name: license_report.license_names[0]) } let(:license) { create(:software_license, name: license_report.license_names[0]) }
let(:license_report) { open_pipeline.license_management_report } let(:license_report) { open_pipeline.license_scanning_report }
specify { expect(subject.approvals_required).to be(project_approval_rule.approvals_required) } specify { expect(subject.approvals_required).to be(project_approval_rule.approvals_required) }
end end
......
...@@ -170,8 +170,8 @@ describe Ci::Build do ...@@ -170,8 +170,8 @@ describe Ci::Build do
end end
end end
describe '#collect_license_management_reports!' do describe '#collect_license_scanning_reports!' do
subject { job.collect_license_management_reports!(license_scanning_report) } subject { job.collect_license_scanning_reports!(license_scanning_report) }
let(:license_scanning_report) { Gitlab::Ci::Reports::LicenseScanning::Report.new } let(:license_scanning_report) { Gitlab::Ci::Reports::LicenseScanning::Report.new }
......
...@@ -239,8 +239,8 @@ describe Ci::Pipeline do ...@@ -239,8 +239,8 @@ describe Ci::Pipeline do
end end
end end
describe '#license_management_reports' do describe '#license_scanning_reports' do
subject { pipeline.license_management_report } subject { pipeline.license_scanning_report }
before do before do
stub_licensed_features(license_management: true) stub_licensed_features(license_management: true)
......
...@@ -73,7 +73,7 @@ describe Security::SyncReportsToApprovalRulesService, '#execute' do ...@@ -73,7 +73,7 @@ describe Security::SyncReportsToApprovalRulesService, '#execute' do
context "when a license violates the license compliance policy" do context "when a license violates the license compliance policy" do
let!(:blacklisted_license) { create(:software_license, name: license_name) } let!(:blacklisted_license) { create(:software_license, name: license_name) }
let!(:ci_build) { create(:ee_ci_build, :success, :license_management, pipeline: pipeline, project: project) } let!(:ci_build) { create(:ee_ci_build, :success, :license_management, pipeline: pipeline, project: project) }
let!(:license_name) { ci_build.pipeline.license_management_report.license_names[0] } let!(:license_name) { ci_build.pipeline.license_scanning_report.license_names[0] }
specify { expect { subject }.not_to change { license_compliance_rule.reload.approvals_required } } specify { expect { subject }.not_to change { license_compliance_rule.reload.approvals_required } }
specify { expect(subject[:status]).to be(:success) } specify { expect(subject[:status]).to be(:success) }
......
...@@ -26,7 +26,7 @@ describe RefreshLicenseComplianceChecksWorker do ...@@ -26,7 +26,7 @@ describe RefreshLicenseComplianceChecksWorker do
let!(:closed_pipeline) { create(:ee_ci_pipeline, :success, :with_license_management_report, project: project, merge_requests_as_head_pipeline: [closed_merge_request]) } let!(:closed_pipeline) { create(:ee_ci_pipeline, :success, :with_license_management_report, project: project, merge_requests_as_head_pipeline: [closed_merge_request]) }
let!(:blacklist_policy) { create(:software_license_policy, project: project, software_license: license, approval_status: :blacklisted) } let!(:blacklist_policy) { create(:software_license_policy, project: project, software_license: license, approval_status: :blacklisted) }
let(:license) { create(:software_license, name: license_report.license_names[0]) } let(:license) { create(:software_license, name: license_report.license_names[0]) }
let(:license_report) { open_pipeline.license_management_report } let(:license_report) { open_pipeline.license_scanning_report }
before do before do
subject.perform(project.id) subject.perform(project.id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment