Commit fd50d49a authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'support-license-management-and-performance-merge-request-widget-ee' into 'master'

Support license management and performance merge request widget

See merge request gitlab-org/gitlab-ee!8043
parents 1d462acd c3ff1702
......@@ -29,12 +29,6 @@ module EE
group_epic_path(entity.group, entity, *args)
end
def license_management_artifact_url(pipeline)
raw_project_build_artifacts_url(pipeline.project,
pipeline.license_management_artifact,
path: Ci::Build::LICENSE_MANAGEMENT_FILE)
end
def license_management_api_url(project)
api_v4_projects_managed_licenses_path(id: project.id)
end
......
......@@ -7,9 +7,6 @@ module EE
module Build
extend ActiveSupport::Concern
LICENSE_MANAGEMENT_FILE = 'gl-license-management-report.json'.freeze
PERFORMANCE_FILE = 'performance.json'.freeze
LICENSED_PARSER_FEATURES = {
sast: :sast
}.with_indifferent_access.freeze
......@@ -34,16 +31,6 @@ module EE
::Gitlab::Database::LoadBalancing::Sticking.stick(:build, id)
end
def has_performance_json?
name_in?(%w[performance deploy]) &&
has_artifact?(PERFORMANCE_FILE)
end
def has_license_management_json?
name_in?('license_management') &&
has_artifact?(LICENSE_MANAGEMENT_FILE)
end
def log_geo_deleted_event
# It is not needed to generate a Geo deleted event
# since Legacy Artifacts are migrated to multi-build artifacts
......
......@@ -27,7 +27,9 @@ module EE
sast: %i[sast],
dependency_scanning: %i[dependency_scanning],
container_scanning: %i[container_scanning sast_container],
dast: %i[dast]
dast: %i[dast],
performance: %i[merge_request_performance_metrics],
license_management: %i[license_management]
}.freeze
# Deprecated, to be removed in 12.0
......@@ -54,6 +56,14 @@ module EE
dast: {
names: %w(dast),
files: %w(gl-dast-report.json)
},
performance: {
names: %w(performance deploy),
files: %w(performance.json)
},
license_management: {
names: %w(license_management),
files: %w(gl-license-management-report.json)
}
}.freeze
......@@ -96,30 +106,8 @@ module EE
nil
end
def performance_artifact
@performance_artifact ||= artifacts_with_files.find(&:has_performance_json?)
end
def license_management_artifact
@license_management_artifact ||= artifacts_with_files.find(&:has_license_management_json?)
end
def has_license_management_data?
license_management_artifact&.success?
end
def has_performance_data?
performance_artifact&.success?
end
def expose_license_management_data?
project.feature_available?(:license_management) &&
has_license_management_data?
end
def expose_performance_data?
project.feature_available?(:merge_request_performance_metrics) &&
has_performance_data?
any_report_artifact_for_type(:license_management)
end
def has_security_reports?
......
......@@ -16,14 +16,8 @@ module EE
validate :validate_approvals_before_merge, unless: :importing?
delegate :performance_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :performance_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :license_management_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :license_management_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :sha, to: :head_pipeline, prefix: :head_pipeline, allow_nil: true
delegate :sha, to: :base_pipeline, prefix: :base_pipeline, allow_nil: true
delegate :has_license_management_data?, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :expose_license_management_data?, to: :head_pipeline, allow_nil: true
delegate :merge_requests_author_approval?, to: :target_project, allow_nil: true
participant :participant_approvers
......@@ -40,11 +34,6 @@ module EE
false
end
def expose_performance_data?
!!(head_pipeline&.expose_performance_data? &&
base_pipeline&.expose_performance_data?)
end
def validate_approvals_before_merge
return true unless approvals_before_merge
return true unless target_project
......
......@@ -26,17 +26,13 @@ module EE
end
end
expose :performance, if: -> (mr, _) { mr.expose_performance_data? } do
expose :head_path, if: -> (mr, _) { can?(current_user, :read_build, mr.head_performance_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
merge_request.head_performance_artifact,
path: Ci::Build::PERFORMANCE_FILE)
expose :performance, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:performance) } do
expose :head_path do |merge_request|
head_pipeline_downloadable_path_for_report_type(:performance)
end
expose :base_path, if: -> (mr, _) { can?(current_user, :read_build, mr.base_performance_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.target_project,
merge_request.base_performance_artifact,
path: Ci::Build::PERFORMANCE_FILE)
expose :base_path do |merge_request|
base_pipeline_downloadable_path_for_report_type(:performance)
end
end
......@@ -60,17 +56,13 @@ module EE
end
end
expose :license_management, if: -> (mr, _) { mr.expose_license_management_data? } do
expose :head_path, if: -> (mr, _) { can?(current_user, :read_build, mr.head_license_management_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
merge_request.head_license_management_artifact,
path: Ci::Build::LICENSE_MANAGEMENT_FILE)
expose :license_management, if: -> (mr, _) { head_pipeline_downloadable_path_for_report_type(:license_management) } do
expose :head_path do |merge_request|
head_pipeline_downloadable_path_for_report_type(:license_management)
end
expose :base_path, if: -> (mr, _) { mr.base_has_license_management_data? && can?(current_user, :read_build, mr.base_license_management_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.target_project,
merge_request.base_license_management_artifact,
path: Ci::Build::LICENSE_MANAGEMENT_FILE)
expose :base_path do |merge_request|
base_pipeline_downloadable_path_for_report_type(:license_management)
end
expose :managed_licenses_path do |merge_request|
......@@ -81,7 +73,7 @@ module EE
can?(current_user, :admin_software_license_policy, merge_request)
end
expose :license_management_settings_path, if: -> (mr, _) {can?(current_user, :admin_software_license_policy, mr.target_project)} do |merge_request|
expose :license_management_settings_path, if: -> (mr, _) { can?(current_user, :admin_software_license_policy, mr.target_project) } do |merge_request|
license_management_settings_path(merge_request.target_project)
end
......
......@@ -27,7 +27,7 @@
- if pipeline.expose_license_management_data?
#js-tab-licenses.tab-pane
#js-licenses-app{ data: { license_head_path: pipeline.expose_license_management_data? ? license_management_artifact_url(pipeline) : nil,
#js-licenses-app{ data: { license_head_path: pipeline.downloadable_path_for_report_type(:license_management),
api_url: license_management_api_url(project),
license_management_settings_path: license_management_settings_path,
can_manage_licenses: can?(current_user, :admin_software_license_policy, project).to_s } }
---
title: Support license management and performance using new reports syntax
merge_request:
author:
type: added
......@@ -15,18 +15,7 @@ describe Projects::PipelinesController do
context 'with a sast artifact' do
before do
create(
:ci_build,
:success,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:sast]]
}
}
)
create(:ee_ci_build, :legacy_sast, pipeline: pipeline)
end
context 'with feature enabled' do
......@@ -83,18 +72,8 @@ describe Projects::PipelinesController do
context 'with a license management artifact' do
before do
create(
:ci_build,
:success,
:artifacts,
name: 'license_management',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::LICENSE_MANAGEMENT_FILE]
}
}
)
build = create(:ci_build, pipeline: pipeline)
create(:ee_ci_job_artifact, :license_management, job: build)
end
context 'with feature enabled' do
......
......@@ -40,7 +40,7 @@ describe Projects::Security::DashboardController do
context 'when uses new reports syntax' do
before do
create(:ee_ci_build, :security_reports, pipeline: pipeline)
create(:ee_ci_build, :sast, pipeline: pipeline)
end
it 'renders empty state (not yet supported)' do
......
......@@ -6,9 +6,25 @@ FactoryBot.define do
failure_reason { Ci::Build.failure_reasons[:protected_environment_failure] }
end
trait :security_reports do
after(:build) do |build|
build.job_artifacts << create(:ee_ci_job_artifact, :sast, job: build)
%i[sast codequality dependency_scanning container_scanning dast performance license_management].each do |report_type|
trait "legacy_#{report_type}".to_sym do
success
artifacts
name report_type
options do
{
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[report_type]]
}
}
end
end
trait report_type do
after(:build) do |build|
build.job_artifacts << build(:ee_ci_job_artifact, report_type, job: build)
end
end
end
end
......
......@@ -21,5 +21,55 @@ FactoryBot.define do
Rails.root.join('ee/spec/fixtures/reports/security/sast_with_corrupted_data.json'), 'application/json')
end
end
trait :performance do
file_format :raw
file_type :performance
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
end
end
trait :license_management do
file_format :raw
file_type :license_management
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
end
end
trait :dependency_scanning do
file_format :raw
file_type :dependency_scanning
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/security-reports/master/gl-dependency-scanning-report.json'), 'text/plain')
end
end
trait :container_scanning do
file_format :raw
file_type :container_scanning
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/security-reports/master/gl-container-scanning-report.json'), 'text/plain')
end
end
trait :dast do
file_format :raw
file_type :dast
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
Rails.root.join('spec/fixtures/security-reports/master/gl-dast-report.json'), 'text/plain')
end
end
end
end
......@@ -18,18 +18,7 @@ describe 'Pipeline', :js do
context 'with a sast artifact' do
before do
create(
:ci_build,
:success,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:sast]]
}
}
)
create(:ee_ci_build, :legacy_sast, pipeline: pipeline)
visit security_project_pipeline_path(project, pipeline)
end
......@@ -66,18 +55,7 @@ describe 'Pipeline', :js do
context 'with a license management artifact' do
before do
create(
:ci_build,
:success,
:artifacts,
name: 'license_management',
pipeline: pipeline,
options: {
artifacts: {
paths: [Ci::Build::LICENSE_MANAGEMENT_FILE]
}
}
)
create(:ee_ci_build, :legacy_license_management, pipeline: pipeline)
visit licenses_project_pipeline_path(project, pipeline)
end
......
......@@ -115,80 +115,11 @@ describe Ci::Build do
end
end
build_artifacts_methods = {
has_performance_json?: {
filename: Ci::Build::PERFORMANCE_FILE,
job_names: %w[performance deploy]
},
has_license_management_json?: {
filename: Ci::Build::LICENSE_MANAGEMENT_FILE,
job_names: %w[license_management]
}
}
build_artifacts_methods.each do |method, requirements|
filename = requirements[:filename]
job_names = requirements[:job_names]
describe "##{method}" do
job_names.each do |job_name|
context "with a job named #{job_name} and a file named #{filename}" do
let(:build) do
create(
:ci_build,
:artifacts,
name: job_name,
pipeline: pipeline,
options: {
artifacts: {
paths: [filename, 'some-other-artifact.txt']
}
}
)
end
it { expect(build.send(method)).to be_truthy }
end
end
context 'with an invalid filename' do
let(:build) do
create(
:ci_build,
:artifacts,
name: job_names.first,
pipeline: pipeline,
options: {}
)
end
it { expect(build.send(method)).to be_falsey }
end
context 'with an invalid job name' do
let(:build) do
create(
:ci_build,
:artifacts,
pipeline: pipeline,
options: {
artifacts: {
paths: [filename, 'some-other-artifact.txt']
}
}
)
end
it { expect(build.send(method)).to be_falsey }
end
end
end
describe '.with_security_reports' do
subject { described_class.with_security_reports }
context 'when build has a security report' do
let!(:build) { create(:ee_ci_build, :success, :security_reports) }
let!(:build) { create(:ee_ci_build, :success, :sast) }
it 'selects the build' do
is_expected.to eq([build])
......@@ -204,7 +135,7 @@ describe Ci::Build do
end
context 'when there are multiple builds with security reports' do
let!(:builds) { create_list(:ee_ci_build, 5, :success, :security_reports) }
let!(:builds) { create_list(:ee_ci_build, 5, :success, :sast) }
it 'does not execute a query for selecting job artifacts one by one' do
recorded = ActiveRecord::QueryRecorder.new do
......
......@@ -20,71 +20,6 @@ describe Ci::Pipeline do
end
end
PIPELINE_ARTIFACTS_METHODS = [
{ method: :performance_artifact, options: [Ci::Build::PERFORMANCE_FILE, 'performance'] },
{ method: :license_management_artifact, options: [Ci::Build::LICENSE_MANAGEMENT_FILE, 'license_management'] }
].freeze
PIPELINE_ARTIFACTS_METHODS.each do |method_test|
method, options = method_test.values_at(:method, :options)
describe method.to_s do
context 'has corresponding job' do
let!(:build) do
filename, name = options
create(
:ci_build,
:artifacts,
name: name,
pipeline: pipeline,
options: {
artifacts: {
paths: [filename]
}
}
)
end
it { expect(pipeline.send(method)).to eq(build) }
end
context 'no corresponding job' do
before do
create(:ci_build, pipeline: pipeline)
end
it { expect(pipeline.send(method)).to be_nil }
end
end
end
%w(performance license_management).each do |type|
method = "has_#{type}_data?"
describe "##{method}" do
let(:artifact) { double(success?: true) }
before do
allow(pipeline).to receive(:"#{type}_artifact").and_return(artifact)
end
it { expect(pipeline.send(method.to_sym)).to be_truthy }
end
end
%w(performance license_management).each do |type|
method = "expose_#{type}_data?"
describe "##{method}" do
before do
allow(pipeline).to receive(:"has_#{type}_data?").and_return(true)
allow(pipeline.project).to receive(:feature_available?).and_return(true)
end
it { expect(pipeline.send(method.to_sym)).to be_truthy }
end
end
describe '#with_legacy_security_reports scope' do
let(:pipeline_1) { create(:ci_pipeline_without_jobs, project: project) }
let(:pipeline_2) { create(:ci_pipeline_without_jobs, project: project) }
......@@ -93,61 +28,11 @@ describe Ci::Pipeline do
let(:pipeline_5) { create(:ci_pipeline_without_jobs, project: project) }
before do
create(
:ci_build,
:success,
:artifacts,
name: 'sast',
pipeline: pipeline_1,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:sast]]
}
}
)
create(
:ci_build,
:success,
:artifacts,
name: 'dependency_scanning',
pipeline: pipeline_2,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:dependency_scanning]]
}
}
)
create(
:ci_build,
:success,
:artifacts,
name: 'container_scanning',
pipeline: pipeline_3,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:container_scanning]]
}
}
)
create(
:ci_build,
:success,
:artifacts,
name: 'dast',
pipeline: pipeline_4,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:dast]]
}
}
)
create(
:ci_build,
:success,
:artifacts,
name: 'foobar',
pipeline: pipeline_5
)
create(:ee_ci_build, :legacy_sast, pipeline: pipeline_1)
create(:ee_ci_build, :legacy_dependency_scanning, pipeline: pipeline_2)
create(:ee_ci_build, :legacy_container_scanning, pipeline: pipeline_3)
create(:ee_ci_build, :legacy_dast, pipeline: pipeline_4)
create(:ee_ci_build, :success, :artifacts, name: 'foobar', pipeline: pipeline_5)
end
it "returns pipeline with security reports" do
......@@ -277,37 +162,12 @@ describe Ci::Pipeline do
end
end
context 'performance' do
def create_build(job_name, filename)
create(
:ci_build,
:artifacts,
name: job_name,
pipeline: pipeline,
options: {
artifacts: {
paths: [filename]
}
}
)
end
it 'does not perform extra queries when calling pipeline artifacts methods after the first' do
create_build('performance', 'performance.json')
create_build('license_management', 'gl-license-management-report.json')
pipeline.performance_artifact
expect { pipeline.license_management_artifact }.not_to exceed_query_limit(0)
end
end
describe '#has_security_reports?' do
subject { pipeline.has_security_reports? }
context 'when pipeline has builds with security reports' do
before do
create(:ee_ci_build, :security_reports, pipeline: pipeline, project: project)
create(:ee_ci_build, :sast, pipeline: pipeline, project: project)
end
context 'when pipeline status is running' do
......@@ -335,7 +195,7 @@ describe Ci::Pipeline do
context 'when retried build has security reports' do
before do
create(:ee_ci_build, :retried, :security_reports, pipeline: pipeline, project: project)
create(:ee_ci_build, :retried, :sast, pipeline: pipeline, project: project)
end
let(:pipeline) { create(:ci_pipeline, :success, project: project) }
......@@ -397,7 +257,7 @@ describe Ci::Pipeline do
let(:default_branch) { pipeline.ref }
before do
create(:ee_ci_build, :security_reports, pipeline: pipeline, project: project)
create(:ee_ci_build, :sast, pipeline: pipeline, project: project)
allow(project).to receive(:default_branch) { default_branch }
end
......
......@@ -40,76 +40,4 @@ describe MergeRequest do
it { expect(subject.base_pipeline).to eq(pipeline) }
end
describe '#base_performance_artifact' do
before do
allow(subject.base_pipeline).to receive(:performance_artifact)
.and_return(1)
end
it 'delegates to merge request diff' do
expect(subject.base_performance_artifact).to eq(1)
end
end
describe '#head_performance_artifact' do
before do
allow(subject.head_pipeline).to receive(:performance_artifact)
.and_return(1)
end
it 'delegates to merge request diff' do
expect(subject.head_performance_artifact).to eq(1)
end
end
describe '#base_license_management_artifact' do
before do
allow(subject.base_pipeline).to receive(:license_management_artifact)
.and_return(1)
end
it 'delegates to merge request diff' do
expect(subject.base_license_management_artifact).to eq(1)
end
end
describe '#head_license_management_artifact' do
before do
allow(subject.head_pipeline).to receive(:license_management_artifact)
.and_return(1)
end
it 'delegates to merge request diff' do
expect(subject.head_license_management_artifact).to eq(1)
end
end
describe '#expose_performance_data?' do
context 'with performance data' do
let(:pipeline) { double(expose_performance_data?: true) }
before do
allow(subject).to receive(:head_pipeline).and_return(pipeline)
allow(subject).to receive(:base_pipeline).and_return(pipeline)
end
it { expect(subject.expose_performance_data?).to be_truthy }
end
context 'without performance data' do
it { expect(subject.expose_performance_data?).to be_falsey }
end
end
describe '#expose_license_management_data?' do
before do
allow(subject.head_pipeline).to receive(:expose_license_management_data?)
.and_return(1)
end
it 'delegates to merge request diff' do
expect(subject.expose_license_management_data?).to eq(1)
end
end
end
......@@ -1503,30 +1503,8 @@ describe Project do
let(:pipeline_3) { create(:ci_pipeline_without_jobs, project: project) }
before do
create(
:ci_build,
:success,
:artifacts,
name: 'sast',
pipeline: pipeline_1,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:sast]]
}
}
)
create(
:ci_build,
:success,
:artifacts,
name: 'sast',
pipeline: pipeline_2,
options: {
artifacts: {
paths: [Ci::JobArtifact::DEFAULT_FILE_NAMES[:sast]]
}
}
)
create(:ee_ci_build, :legacy_sast, pipeline: pipeline_1)
create(:ee_ci_build, :legacy_sast, pipeline: pipeline_2)
end
it "returns the latest pipeline with security reports" do
......
require 'spec_helper'
describe MergeRequestWidgetEntity do
let(:user) { create(:user) }
let(:project) { create :project, :repository }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
set(:user) { create(:user) }
set(:project) { create :project, :repository }
set(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
set(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:request) { double('request', current_user: user) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
before do
project.add_developer(user)
......@@ -39,6 +39,8 @@ describe MergeRequestWidgetEntity do
:dependency_scanning | :dependency_scanning
:sast_container | :container_scanning
:dast | :dast
:license_management | :license_management
:performance | :performance
end
with_them do
......@@ -54,10 +56,9 @@ describe MergeRequestWidgetEntity do
allow(pipeline).to receive(:available_licensed_report_type?).and_return(true)
end
context "with data" do
context "with new report artifacts" do
before do
job = create(:ci_build, pipeline: pipeline)
create(:ci_job_artifact, file_type: artifact_type, file_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS[artifact_type], job: job)
create(:ee_ci_build, artifact_type, pipeline: pipeline)
end
it "has data entry" do
......@@ -65,7 +66,17 @@ describe MergeRequestWidgetEntity do
end
end
context "without data" do
context "with legacy report artifacts" do
before do
create(:ee_ci_build, :"legacy_#{artifact_type}", pipeline: pipeline)
end
it "has data entry" do
expect(subject.as_json).to include(json_entry)
end
end
context "without artifacts" do
it "does not have data entry" do
expect(subject.as_json).not_to include(json_entry)
end
......@@ -74,56 +85,69 @@ describe MergeRequestWidgetEntity do
end
end
it 'has performance data' do
build = create(:ci_build, name: 'job')
allow(merge_request).to receive_messages(
expose_performance_data?: true,
base_performance_artifact: build,
head_performance_artifact: build
)
expect(subject.as_json).to include(:performance)
end
describe '#license_management' do
before do
build = create(:ci_build, name: 'license_management', pipeline: pipeline)
allow(merge_request).to receive_messages(
expose_license_management_data?: true,
base_has_license_management_data?: true,
base_license_management_artifact: build,
head_license_management_artifact: build,
head_pipeline: pipeline,
target_project: project
)
head_pipeline: pipeline, target_project: project)
stub_licensed_features(license_management: true)
end
it 'should not be included, if license management features are off' do
allow(merge_request).to receive_messages(expose_license_management_data?: false)
it 'should not be included, if missing artifacts' do
expect(subject.as_json).not_to include(:license_management)
end
it 'should be included, if license manage management features are on' do
expect(subject.as_json).to include(:license_management)
expect(subject.as_json[:license_management]).to include(:head_path)
expect(subject.as_json[:license_management]).to include(:base_path)
expect(subject.as_json[:license_management]).to include(:managed_licenses_path)
expect(subject.as_json[:license_management]).to include(:can_manage_licenses)
expect(subject.as_json[:license_management]).to include(:license_management_full_report_path)
end
context 'when report artifact is defined' do
before do
create(:ee_ci_build, :license_management, pipeline: pipeline)
end
it '#license_management_settings_path should not be included for developers' do
expect(subject.as_json[:license_management]).not_to include(:license_management_settings_path)
it 'should be included' do
expect(subject.as_json).to include(:license_management)
expect(subject.as_json[:license_management]).to include(:head_path)
expect(subject.as_json[:license_management]).to include(:base_path)
expect(subject.as_json[:license_management]).to include(:managed_licenses_path)
expect(subject.as_json[:license_management]).to include(:can_manage_licenses)
expect(subject.as_json[:license_management]).to include(:license_management_full_report_path)
end
context 'when feature is not licensed' do
before do
stub_licensed_features(license_management: false)
end
it 'should not be included' do
expect(subject.as_json).not_to include(:license_management)
end
end
it '#license_management_settings_path should not be included for developers' do
expect(subject.as_json[:license_management]).not_to include(:license_management_settings_path)
end
context 'when user is maintainer' do
before do
project.add_maintainer(user)
end
it '#license_management_settings_path should be included for maintainers' do
expect(subject.as_json[:license_management]).to include(:license_management_settings_path)
end
end
end
it '#license_management_settings_path should be included for maintainers' do
stub_licensed_features(license_management: true)
project.add_maintainer(user)
context 'when legacy artifact is defined' do
before do
create(:ee_ci_build, :legacy_license_management, pipeline: pipeline)
end
expect(subject.as_json[:license_management]).to include(:license_management_settings_path)
it 'should be included, if license manage management features are on' do
expect(subject.as_json).to include(:license_management)
expect(subject.as_json[:license_management]).to include(:head_path)
expect(subject.as_json[:license_management]).to include(:base_path)
expect(subject.as_json[:license_management]).to include(:managed_licenses_path)
expect(subject.as_json[:license_management]).to include(:can_manage_licenses)
expect(subject.as_json[:license_management]).to include(:license_management_full_report_path)
end
end
end
......
......@@ -10,7 +10,7 @@ describe Security::StoreReportsService, '#execute' do
context 'when there are reports' do
before do
stub_licensed_features(sast: true)
create(:ee_ci_build, :security_reports, pipeline: pipeline)
create(:ee_ci_build, :sast, pipeline: pipeline)
end
it 'initializes a new StoreReportService and execute it' do
......
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