Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d43d00da
Commit
d43d00da
authored
Feb 18, 2020
by
Tetiana Chupryna
Committed by
Peter Leitzen
Feb 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add license_scanning report key
We'll drop license_management when FE is done
parent
be1edb93
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
32 deletions
+95
-32
ee/app/models/ee/merge_request.rb
ee/app/models/ee/merge_request.rb
+2
-1
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+19
-0
ee/spec/models/merge_request_spec.rb
ee/spec/models/merge_request_spec.rb
+1
-0
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+73
-31
No files found.
ee/app/models/ee/merge_request.rb
View file @
d43d00da
...
@@ -177,7 +177,8 @@ module EE
...
@@ -177,7 +177,8 @@ module EE
container_scanning:
report_type_enabled?
(
:container_scanning
),
container_scanning:
report_type_enabled?
(
:container_scanning
),
dast:
report_type_enabled?
(
:dast
),
dast:
report_type_enabled?
(
:dast
),
dependency_scanning:
report_type_enabled?
(
:dependency_scanning
),
dependency_scanning:
report_type_enabled?
(
:dependency_scanning
),
license_management:
report_type_enabled?
(
:license_scanning
)
license_management:
report_type_enabled?
(
:license_scanning
),
license_scanning:
report_type_enabled?
(
:license_scanning
)
}
}
end
end
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
d43d00da
...
@@ -40,6 +40,7 @@ module EE
...
@@ -40,6 +40,7 @@ module EE
merge_request
.
enabled_reports
merge_request
.
enabled_reports
end
end
# TODO: remove after https://gitlab.com/gitlab-org/gitlab/issues/205304 is done
expose
:license_management
,
if:
->
(
mr
,
_
)
{
head_pipeline_downloadable_path_for_report_type
(
:license_management
)
}
do
expose
:license_management
,
if:
->
(
mr
,
_
)
{
head_pipeline_downloadable_path_for_report_type
(
:license_management
)
}
do
expose
:managed_licenses_path
do
|
merge_request
|
expose
:managed_licenses_path
do
|
merge_request
|
expose_path
(
api_v4_projects_managed_licenses_path
(
id:
merge_request
.
target_project
.
id
))
expose_path
(
api_v4_projects_managed_licenses_path
(
id:
merge_request
.
target_project
.
id
))
...
@@ -58,6 +59,24 @@ module EE
...
@@ -58,6 +59,24 @@ module EE
end
end
end
end
expose
:license_scanning
,
if:
->
(
mr
,
_
)
{
head_pipeline_downloadable_path_for_report_type
(
:license_scanning
)
}
do
expose
:managed_licenses_path
do
|
merge_request
|
expose_path
(
api_v4_projects_managed_licenses_path
(
id:
merge_request
.
target_project
.
id
))
end
expose
:can_manage_licenses
do
|
merge_request
|
can?
(
current_user
,
:admin_software_license_policy
,
merge_request
)
end
expose
: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
expose
:full_report_path
,
if:
->
(
mr
,
_
)
{
mr
.
head_pipeline
}
do
|
merge_request
|
licenses_project_pipeline_path
(
merge_request
.
target_project
,
merge_request
.
head_pipeline
)
end
end
expose
:metrics_reports_path
,
if:
->
(
mr
,
_
)
{
mr
.
has_metrics_reports?
}
do
|
merge_request
|
expose
:metrics_reports_path
,
if:
->
(
mr
,
_
)
{
mr
.
has_metrics_reports?
}
do
|
merge_request
|
metrics_reports_project_merge_request_path
(
merge_request
.
project
,
merge_request
,
format: :json
)
metrics_reports_project_merge_request_path
(
merge_request
.
project
,
merge_request
,
format: :json
)
end
end
...
...
ee/spec/models/merge_request_spec.rb
View file @
d43d00da
...
@@ -128,6 +128,7 @@ describe MergeRequest do
...
@@ -128,6 +128,7 @@ describe MergeRequest do
:dependency_scanning
|
:with_dependency_scanning_reports
|
:dependency_scanning
:dependency_scanning
|
:with_dependency_scanning_reports
|
:dependency_scanning
:license_management
|
:with_license_management_reports
|
:license_management
:license_management
|
:with_license_management_reports
|
:license_management
:license_management
|
:with_license_scanning_reports
|
:license_management
:license_management
|
:with_license_scanning_reports
|
:license_management
:license_scanning
|
:with_license_scanning_reports
|
:license_management
end
end
with_them
do
with_them
do
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
d43d00da
...
@@ -59,37 +59,6 @@ describe MergeRequestWidgetEntity do
...
@@ -59,37 +59,6 @@ describe MergeRequestWidgetEntity do
expect
{
serializer
.
represent
(
merge_request
)
}.
not_to
exceed_query_limit
(
control
)
expect
{
serializer
.
represent
(
merge_request
)
}.
not_to
exceed_query_limit
(
control
)
end
end
describe
'enabled_reports'
do
it
'marks all reports as disabled by default'
do
expect
(
subject
.
as_json
).
to
include
(
:enabled_reports
)
expect
(
subject
.
as_json
[
:enabled_reports
]).
to
eq
({
sast:
false
,
container_scanning:
false
,
dast:
false
,
dependency_scanning:
false
,
license_management:
false
})
end
it
'marks reports as enabled if artifacts exist'
do
allow
(
merge_request
).
to
receive
(
:enabled_reports
).
and_return
({
sast:
true
,
container_scanning:
true
,
dast:
true
,
dependency_scanning:
true
,
license_management:
true
})
expect
(
subject
.
as_json
).
to
include
(
:enabled_reports
)
expect
(
subject
.
as_json
[
:enabled_reports
]).
to
eq
({
sast:
true
,
container_scanning:
true
,
dast:
true
,
dependency_scanning:
true
,
license_management:
true
})
end
end
describe
'test report artifacts'
,
:request_store
do
describe
'test report artifacts'
,
:request_store
do
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
...
@@ -206,6 +175,79 @@ describe MergeRequestWidgetEntity do
...
@@ -206,6 +175,79 @@ describe MergeRequestWidgetEntity do
end
end
end
end
describe
'#license_scanning'
,
:request_store
do
before
do
allow
(
merge_request
).
to
receive_messages
(
head_pipeline:
pipeline
,
target_project:
project
)
stub_licensed_features
(
license_management:
true
)
end
it
'is not included, if missing artifacts'
do
expect
(
subject
.
as_json
).
not_to
include
(
:license_scanning
)
end
context
'when report artifact is defined'
do
before
do
create
(
:ee_ci_build
,
:license_scanning
,
pipeline:
pipeline
)
end
it
'is included'
do
expect
(
subject
.
as_json
[
:license_scanning
]).
to
include
(
:can_manage_licenses
)
expect
(
subject
.
as_json
[
:license_scanning
]).
to
include
(
:full_report_path
)
end
it
'#settings_path should not be included for developers'
do
expect
(
subject
.
as_json
[
:license_scanning
]).
not_to
include
(
:settings_path
)
end
context
'when feature is not licensed'
do
before
do
stub_licensed_features
(
license_management:
false
)
end
it
'is not included'
do
expect
(
subject
.
as_json
).
not_to
include
(
:license_scanning
)
end
end
context
'when user is maintainer'
do
before
do
project
.
add_maintainer
(
user
)
end
it
'#settings_path should be included for maintainers'
do
expect
(
subject
.
as_json
[
:license_scanning
]).
to
include
(
:settings_path
)
end
end
end
describe
'#managed_licenses_path'
do
let
(
:managed_licenses_path
)
{
expose_path
(
api_v4_projects_managed_licenses_path
(
id:
project
.
id
))
}
before
do
create
(
:ee_ci_build
,
:license_scanning
,
pipeline:
pipeline
)
end
it
'is a path for target project'
do
expect
(
subject
.
as_json
[
:license_scanning
][
:managed_licenses_path
]).
to
eq
(
managed_licenses_path
)
end
context
'with fork'
do
let
(
:source_project
)
{
fork_project
(
project
,
user
,
repository:
true
)
}
let
(
:fork_merge_request
)
{
create
(
:merge_request
,
source_project:
source_project
,
target_project:
project
)
}
let
(
:subject_json
)
{
described_class
.
new
(
fork_merge_request
,
current_user:
user
,
request:
request
).
as_json
}
before
do
allow
(
fork_merge_request
).
to
receive_messages
(
head_pipeline:
pipeline
)
stub_licensed_features
(
license_management:
true
)
end
it
'is a path for target project'
do
expect
(
subject_json
[
:license_scanning
][
:managed_licenses_path
]).
to
eq
(
managed_licenses_path
)
end
end
end
end
it
'has vulnerability feedback paths'
do
it
'has vulnerability feedback paths'
do
expect
(
subject
.
as_json
[
:vulnerability_feedback_path
]).
to
eq
(
expect
(
subject
.
as_json
[
:vulnerability_feedback_path
]).
to
eq
(
"/
#{
merge_request
.
project
.
full_path
}
/-/vulnerability_feedback"
"/
#{
merge_request
.
project
.
full_path
}
/-/vulnerability_feedback"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment