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
655279d6
Commit
655279d6
authored
Dec 11, 2019
by
mo khan
Committed by
Ash McKenzie
Dec 12, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply maintainer feedback
parent
0c6a47c6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
17 additions
and
21 deletions
+17
-21
ee/app/models/software_license_policy.rb
ee/app/models/software_license_policy.rb
+8
-0
ee/app/serializers/license_scanning_report_license_entity.rb
ee/app/serializers/license_scanning_report_license_entity.rb
+1
-1
ee/app/serializers/managed_license_entity.rb
ee/app/serializers/managed_license_entity.rb
+1
-4
ee/app/services/software_license_policies/create_service.rb
ee/app/services/software_license_policies/create_service.rb
+1
-5
ee/app/services/software_license_policies/update_service.rb
ee/app/services/software_license_policies/update_service.rb
+1
-7
ee/lib/ee/api/entities.rb
ee/lib/ee/api/entities.rb
+1
-4
ee/spec/serializers/license_scanning_report_license_entity_spec.rb
...erializers/license_scanning_report_license_entity_spec.rb
+4
-0
No files found.
ee/app/models/software_license_policy.rb
View file @
655279d6
...
@@ -47,7 +47,15 @@ class SoftwareLicensePolicy < ApplicationRecord
...
@@ -47,7 +47,15 @@ class SoftwareLicensePolicy < ApplicationRecord
delegate
:name
,
:spdx_identifier
,
to: :software_license
delegate
:name
,
:spdx_identifier
,
to: :software_license
def
approval_status
APPROVAL_STATUS
.
key
(
classification
)
||
classification
end
def
self
.
workaround_cache_key
def
self
.
workaround_cache_key
pluck
(
:id
,
:classification
).
flatten
pluck
(
:id
,
:classification
).
flatten
end
end
def
self
.
to_classification
(
approval_status
)
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
end
end
end
ee/app/serializers/license_scanning_report_license_entity.rb
View file @
655279d6
...
@@ -10,7 +10,7 @@ class LicenseScanningReportLicenseEntity < Grape::Entity
...
@@ -10,7 +10,7 @@ class LicenseScanningReportLicenseEntity < Grape::Entity
expose
:url
expose
:url
def
classification
def
classification
default
=
{
id:
nil
,
name:
value_for
(
:name
),
classification
:
'unclassified'
}
default
=
{
id:
nil
,
name:
value_for
(
:name
),
approval_status
:
'unclassified'
}
found
=
SoftwareLicensePoliciesFinder
.
new
(
request
&
.
current_user
,
request
&
.
project
,
name:
value_for
(
:name
)).
find
found
=
SoftwareLicensePoliciesFinder
.
new
(
request
&
.
current_user
,
request
&
.
project
,
name:
value_for
(
:name
)).
find
ManagedLicenseEntity
.
represent
(
found
||
default
)
ManagedLicenseEntity
.
represent
(
found
||
default
)
end
end
...
...
ee/app/serializers/managed_license_entity.rb
View file @
655279d6
...
@@ -2,10 +2,7 @@
...
@@ -2,10 +2,7 @@
class
ManagedLicenseEntity
<
Grape
::
Entity
class
ManagedLicenseEntity
<
Grape
::
Entity
expose
:id
expose
:id
expose
:classification
,
as: :approval_status
do
|
policy
|
expose
:approval_status
classification
=
policy
[
:classification
]
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
key
(
classification
)
||
classification
end
expose
:software_license
,
merge:
true
do
expose
:software_license
,
merge:
true
do
expose
:name
expose
:name
end
end
...
...
ee/app/services/software_license_policies/create_service.rb
View file @
655279d6
...
@@ -24,14 +24,10 @@ module SoftwareLicensePolicies
...
@@ -24,14 +24,10 @@ module SoftwareLicensePolicies
policy
=
SoftwareLicense
.
create_policy_for!
(
policy
=
SoftwareLicense
.
create_policy_for!
(
project:
project
,
project:
project
,
name:
params
[
:name
],
name:
params
[
:name
],
classification:
map_from
(
params
[
:approval_status
])
classification:
SoftwareLicensePolicy
.
to_classification
(
params
[
:approval_status
])
)
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
policy
policy
end
end
def
map_from
(
approval_status
)
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
end
end
end
end
end
ee/app/services/software_license_policies/update_service.rb
View file @
655279d6
...
@@ -11,17 +11,11 @@ module SoftwareLicensePolicies
...
@@ -11,17 +11,11 @@ module SoftwareLicensePolicies
return
error
(
""
,
403
)
unless
can?
(
@current_user
,
:admin_software_license_policy
,
@project
)
return
error
(
""
,
403
)
unless
can?
(
@current_user
,
:admin_software_license_policy
,
@project
)
return
success
(
software_license_policy:
software_license_policy
)
unless
params
[
:approval_status
].
present?
return
success
(
software_license_policy:
software_license_policy
)
unless
params
[
:approval_status
].
present?
software_license_policy
.
update
(
classification:
map_from
(
params
[
:approval_status
]))
software_license_policy
.
update
(
classification:
SoftwareLicensePolicy
.
to_classification
(
params
[
:approval_status
]))
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
RefreshLicenseComplianceChecksWorker
.
perform_async
(
project
.
id
)
success
(
software_license_policy:
software_license_policy
)
success
(
software_license_policy:
software_license_policy
)
rescue
ArgumentError
=>
ex
rescue
ArgumentError
=>
ex
error
(
ex
.
message
,
400
)
error
(
ex
.
message
,
400
)
end
end
private
def
map_from
(
approval_status
)
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
fetch
(
approval_status
,
approval_status
)
end
end
end
end
end
ee/lib/ee/api/entities.rb
View file @
655279d6
...
@@ -861,10 +861,7 @@ module EE
...
@@ -861,10 +861,7 @@ module EE
class
ManagedLicense
<
Grape
::
Entity
class
ManagedLicense
<
Grape
::
Entity
expose
:id
,
:name
expose
:id
,
:name
expose
:classification
,
as: :approval_status
do
|
policy
|
expose
:approval_status
SoftwareLicensePolicy
::
APPROVAL_STATUS
.
key
(
policy
.
classification
)
||
policy
.
classification
end
end
end
class
ProjectAlias
<
Grape
::
Entity
class
ProjectAlias
<
Grape
::
Entity
...
...
ee/spec/serializers/license_scanning_report_license_entity_spec.rb
View file @
655279d6
...
@@ -19,6 +19,10 @@ describe LicenseScanningReportLicenseEntity do
...
@@ -19,6 +19,10 @@ describe LicenseScanningReportLicenseEntity do
describe
'#as_json'
do
describe
'#as_json'
do
subject
{
entity
.
as_json
}
subject
{
entity
.
as_json
}
it
'emits the correct approval_status'
do
expect
(
subject
[
:classification
][
:approval_status
]).
to
eq
(
'unclassified'
)
end
it
'contains the correct dependencies'
do
it
'contains the correct dependencies'
do
expect
(
subject
[
:dependencies
].
count
).
to
eq
(
2
)
expect
(
subject
[
:dependencies
].
count
).
to
eq
(
2
)
expect
(
subject
[
:dependencies
][
0
][
:name
]).
to
eq
(
'Dependency1'
)
expect
(
subject
[
:dependencies
][
0
][
:name
]).
to
eq
(
'Dependency1'
)
...
...
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