Commit 88bbefa0 authored by Tetiana Chupryna's avatar Tetiana Chupryna Committed by Sean McGivern

Rename License Management report

Rename report and its components with tests

Fix usage of License Scanning report

Replace name in all found places

Update usage of the report

Fix usage of the report
parent 7cea781a
......@@ -134,7 +134,7 @@ module EE
end
def license_management_report
::Gitlab::Ci::Reports::LicenseManagement::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|
build.collect_license_management_reports!(license_management_report)
end
......
......@@ -10,7 +10,7 @@ module Gitlab
attr_reader :base_report, :head_report
def initialize(base_report, head_report)
@base_report = base_report || ::Gitlab::Ci::Reports::LicenseManagement::Report.new
@base_report = base_report || ::Gitlab::Ci::Reports::LicenseScanning::Report.new
@head_report = head_report
end
......
......@@ -3,7 +3,7 @@
module Gitlab
module Ci
module Reports
module LicenseManagement
module LicenseScanning
class Dependency
attr_reader :name
......
......@@ -3,7 +3,7 @@
module Gitlab
module Ci
module Reports
module LicenseManagement
module LicenseScanning
class License
attr_reader :name, :url, :count
......@@ -15,7 +15,7 @@ module Gitlab
end
def add_dependency(name)
@dependencies.add(::Gitlab::Ci::Reports::LicenseManagement::Dependency.new(name))
@dependencies.add(::Gitlab::Ci::Reports::LicenseScanning::Dependency.new(name))
end
def dependencies
......
......@@ -3,7 +3,7 @@
module Gitlab
module Ci
module Reports
module LicenseManagement
module LicenseScanning
class Report
attr_reader :found_licenses
......@@ -21,7 +21,7 @@ module Gitlab
def add_dependency(license_name, license_count, license_url, dependency_name)
key = license_name.upcase
found_licenses[key] ||= ::Gitlab::Ci::Reports::LicenseManagement::License.new(license_name, license_count, license_url)
found_licenses[key] ||= ::Gitlab::Ci::Reports::LicenseScanning::License.new(license_name, license_count, license_url)
found_licenses[key].add_dependency(dependency_name)
end
......
# frozen_string_literal: true
FactoryBot.define do
factory :ci_reports_license_management_report, class: ::Gitlab::Ci::Reports::LicenseManagement::Report do
factory :ci_reports_license_management_report, class: ::Gitlab::Ci::Reports::LicenseScanning::Report do
trait :report_1 do
after(:build) do |report, evaluator|
report.add_dependency('MIT', 1, 'https://opensource.org/licenses/mit', 'Library1')
......
......@@ -6,7 +6,7 @@ describe Gitlab::Ci::Parsers::LicenseCompliance::LicenseScanning do
describe '#parse!' do
subject { described_class.new.parse!(data, report) }
let(:report) { Gitlab::Ci::Reports::LicenseManagement::Report.new }
let(:report) { Gitlab::Ci::Reports::LicenseScanning::Report.new }
context 'when data is a JSON license management report' do
let(:data) { File.read(Rails.root.join('ee/spec/fixtures/security_reports/master/gl-license-management-report.json')) }
......
......@@ -2,7 +2,7 @@
require 'spec_helper'
describe Gitlab::Ci::Reports::LicenseManagement::Report do
describe Gitlab::Ci::Reports::LicenseScanning::Report do
subject { build(:ci_reports_license_management_report, :mit) }
describe '#violates?' do
......
......@@ -171,18 +171,18 @@ describe Ci::Build do
end
describe '#collect_license_management_reports!' do
subject { job.collect_license_management_reports!(license_management_report) }
subject { job.collect_license_management_reports!(license_scanning_report) }
let(:license_management_report) { Gitlab::Ci::Reports::LicenseManagement::Report.new }
let(:license_scanning_report) { Gitlab::Ci::Reports::LicenseScanning::Report.new }
before do
stub_licensed_features(license_management: true)
end
it { expect(license_management_report.licenses.count).to eq(0) }
it { expect(license_scanning_report.licenses.count).to eq(0) }
context 'when build has a license management report' do
context 'when there is a license management report' do
context 'when there is a license scanning report' do
before do
create(:ee_ci_job_artifact, :license_management, job: job, project: job.project)
end
......@@ -190,9 +190,9 @@ describe Ci::Build do
it 'parses blobs and add the results to the report' do
expect { subject }.not_to raise_error
expect(license_management_report.licenses.count).to eq(4)
expect(license_management_report.found_licenses['MIT'].name).to eq('MIT')
expect(license_management_report.found_licenses['MIT'].dependencies.count).to eq(52)
expect(license_scanning_report.licenses.count).to eq(4)
expect(license_scanning_report.found_licenses['MIT'].name).to eq('MIT')
expect(license_scanning_report.found_licenses['MIT'].dependencies.count).to eq(52)
end
end
......@@ -206,16 +206,16 @@ describe Ci::Build do
end
end
context 'when Feature flag is disabled for License Management reports parsing' do
context 'when Feature flag is disabled for License Scanning reports parsing' do
before do
stub_feature_flags(parse_license_management_reports: false)
create(:ee_ci_job_artifact, :license_management, job: job, project: job.project)
end
it 'does NOT parse license management report' do
it 'does NOT parse license scanning report' do
subject
expect(license_management_report.licenses.count).to eq(0)
expect(license_scanning_report.licenses.count).to eq(0)
end
end
......@@ -225,10 +225,10 @@ describe Ci::Build do
create(:ee_ci_job_artifact, :license_management, job: job, project: job.project)
end
it 'does NOT parse license management report' do
it 'does NOT parse license scanning report' do
subject
expect(license_management_report.licenses.count).to eq(0)
expect(license_scanning_report.licenses.count).to eq(0)
end
end
end
......
......@@ -255,7 +255,7 @@ describe Ci::Pipeline do
create(:ee_ci_job_artifact, :license_management_feature_branch, job: build_2, project: project)
end
it 'returns a license management report with collected data' do
it 'returns a license scanning report with collected data' do
expect(subject.licenses.count).to eq(5)
expect(subject.licenses.map(&:name)).to include('WTFPL', 'MIT')
end
......@@ -271,7 +271,7 @@ describe Ci::Pipeline do
end
context 'when pipeline does not have any builds with license management reports' do
it 'returns an empty license management report' do
it 'returns an empty license scanning report' do
expect(subject.licenses).to be_empty
end
end
......
......@@ -88,7 +88,7 @@ describe Security::SyncReportsToApprovalRulesService, '#execute' do
context "when an unexpected error occurs" do
before do
allow_any_instance_of(Gitlab::Ci::Reports::LicenseManagement::Report).to receive(:violates?).and_raise('heck')
allow_any_instance_of(Gitlab::Ci::Reports::LicenseScanning::Report).to receive(:violates?).and_raise('heck')
end
specify { expect(subject[:status]).to be(:error) }
......
......@@ -2,7 +2,7 @@
module LicenseManagementReportHelper
def create_report(dependencies)
Gitlab::Ci::Reports::LicenseManagement::Report.new.tap do |report|
Gitlab::Ci::Reports::LicenseScanning::Report.new.tap do |report|
dependencies.each do |license_name, dependencies|
dependencies.each do |dependency_name|
report.add_dependency(license_name.to_s, 1, "https://opensource.org/licenses/license1", dependency_name)
......@@ -32,13 +32,13 @@ module LicenseManagementReportHelper
end
def create_license
Gitlab::Ci::Reports::LicenseManagement::License.new('License1', 1, "https://opensource.org/licenses/license1").tap do |license|
Gitlab::Ci::Reports::LicenseScanning::License.new('License1', 1, "https://opensource.org/licenses/license1").tap do |license|
license.add_dependency('Dependency1')
license.add_dependency('Dependency2')
end
end
def create_dependency
Gitlab::Ci::Reports::LicenseManagement::Dependency.new('Dependency1')
Gitlab::Ci::Reports::LicenseScanning::Dependency.new('Dependency1')
end
end
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