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
e60c2dbb
Commit
e60c2dbb
authored
Jan 07, 2020
by
mo khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow filtering policies by x AND y classification
parent
b3e77e34
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
ee/app/controllers/projects/licenses_controller.rb
ee/app/controllers/projects/licenses_controller.rb
+3
-2
ee/spec/controllers/projects/licenses_controller_spec.rb
ee/spec/controllers/projects/licenses_controller_spec.rb
+30
-1
No files found.
ee/app/controllers/projects/licenses_controller.rb
View file @
e60c2dbb
...
@@ -68,9 +68,10 @@ module Projects
...
@@ -68,9 +68,10 @@ module Projects
def
matching_policies_from
(
license_compliance
)
def
matching_policies_from
(
license_compliance
)
if
params
[
:detected
]
if
params
[
:detected
]
license_compliance
.
detected_policies
license_compliance
.
detected_policies
elsif
params
[
:classifications
].
present?
elsif
params
[
:classification
].
present?
classifications
=
Array
(
params
[
:classification
])
license_compliance
.
policies
.
find_all
do
|
policy
|
license_compliance
.
policies
.
find_all
do
|
policy
|
params
[
:classifications
]
.
include?
(
policy
.
classification
)
classifications
.
include?
(
policy
.
classification
)
end
end
else
else
license_compliance
.
policies
license_compliance
.
policies
...
...
ee/spec/controllers/projects/licenses_controller_spec.rb
View file @
e60c2dbb
...
@@ -178,7 +178,7 @@ describe Projects::LicensesController do
...
@@ -178,7 +178,7 @@ describe Projects::LicensesController do
get
:index
,
params:
{
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
namespace_id:
project
.
namespace
,
project_id:
project
,
project_id:
project
,
classification
s
:
[
'allowed'
]
classification:
[
'allowed'
]
},
format: :json
},
format: :json
end
end
...
@@ -193,6 +193,35 @@ describe Projects::LicensesController do
...
@@ -193,6 +193,35 @@ describe Projects::LicensesController do
})
})
end
end
end
end
context
"when loading `allowed` and `denied` software policies"
do
before
do
get
:index
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
classification:
[
'allowed'
,
'denied'
]
},
format: :json
end
it
{
expect
(
response
).
to
have_http_status
(
:ok
)
}
it
{
expect
(
json_response
[
"licenses"
].
count
).
to
be
(
2
)
}
it
'includes `denied` policies'
do
expect
(
json_response
.
dig
(
"licenses"
,
0
)).
to
include
({
"id"
=>
mit_policy
.
id
,
"spdx_identifier"
=>
mit
.
spdx_identifier
,
"classification"
=>
mit_policy
.
classification
})
end
it
'includes `allowed` policies'
do
expect
(
json_response
.
dig
(
"licenses"
,
1
)).
to
include
({
"id"
=>
other_license_policy
.
id
,
"spdx_identifier"
=>
other_license_policy
.
spdx_identifier
,
"classification"
=>
other_license_policy
.
classification
})
end
end
end
end
context
'without existing report'
do
context
'without existing report'
do
...
...
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