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