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
6268189d
Commit
6268189d
authored
Jul 12, 2019
by
Avielle Wolfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up VulnerabilitiesActions shared examples
There was some unnecessary duplication.
parent
c215198d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
17 deletions
+5
-17
ee/spec/support/shared_examples/controllers/concerns/vulnerabilities_actions_shared_examples.rb
...llers/concerns/vulnerabilities_actions_shared_examples.rb
+5
-17
No files found.
ee/spec/support/shared_examples/controllers/concerns/vulnerabilities_actions_shared_examples.rb
View file @
6268189d
...
@@ -50,7 +50,6 @@ shared_examples VulnerabilitiesActions do
...
@@ -50,7 +50,6 @@ shared_examples VulnerabilitiesActions do
subject
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
length
).
to
eq
15
expect
(
json_response
.
length
).
to
eq
15
end
end
end
end
...
@@ -86,18 +85,16 @@ shared_examples VulnerabilitiesActions do
...
@@ -86,18 +85,16 @@ shared_examples VulnerabilitiesActions do
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :sast
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :sast
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :dast
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :dast
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :dependency_scanning
)
create
(
:vulnerabilities_occurrence
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :dependency_scanning
)
subject
end
end
context
'with a single report filter'
do
context
'with a single report filter'
do
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
[
'sast'
])
}
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
[
'sast'
])
}
it
'returns a list of vulnerabilities for that reporty type only'
do
it
'returns a list of vulnerabilities for that reporty type only'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
.
length
).
to
eq
1
expect
(
json_response
.
length
).
to
eq
1
expect
(
json_response
.
map
{
|
v
|
v
[
'report_type'
]
}.
uniq
).
to
contain_exactly
(
'sast'
)
expect
(
json_response
.
map
{
|
v
|
v
[
'report_type'
]
}.
uniq
).
to
contain_exactly
(
'sast'
)
expect
(
response
).
to
match_response_schema
(
'vulnerabilities/occurrence_list'
,
dir:
'ee'
)
end
end
end
end
...
@@ -105,8 +102,6 @@ shared_examples VulnerabilitiesActions do
...
@@ -105,8 +102,6 @@ shared_examples VulnerabilitiesActions do
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
%w[sast dependency_scanning]
)
}
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
%w[sast dependency_scanning]
)
}
it
'returns a list of vulnerabilities for all filtered upon types'
do
it
'returns a list of vulnerabilities for all filtered upon types'
do
subject
expect
(
json_response
.
length
).
to
eq
2
expect
(
json_response
.
length
).
to
eq
2
expect
(
json_response
.
map
{
|
v
|
v
[
'report_type'
]
}.
uniq
).
to
contain_exactly
(
'sast'
,
'dependency_scanning'
)
expect
(
json_response
.
map
{
|
v
|
v
[
'report_type'
]
}.
uniq
).
to
contain_exactly
(
'sast'
,
'dependency_scanning'
)
end
end
...
@@ -126,11 +121,11 @@ shared_examples VulnerabilitiesActions do
...
@@ -126,11 +121,11 @@ shared_examples VulnerabilitiesActions do
pipelines:
[
pipeline
],
project:
project
,
report_type: :dast
,
severity: :medium
)
pipelines:
[
pipeline
],
project:
project
,
report_type: :dast
,
severity: :medium
)
create_list
(
:vulnerabilities_occurrence
,
1
,
create_list
(
:vulnerabilities_occurrence
,
1
,
pipelines:
[
pipeline
],
project:
project
,
report_type: :sast
,
severity: :medium
)
pipelines:
[
pipeline
],
project:
project
,
report_type: :sast
,
severity: :medium
)
end
it
'returns vulnerabilities counts for all report types'
do
subject
subject
end
it
'returns vulnerabilities counts for all report types'
do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'high'
]).
to
eq
(
3
)
expect
(
json_response
[
'high'
]).
to
eq
(
3
)
expect
(
json_response
[
'low'
]).
to
eq
(
2
)
expect
(
json_response
[
'low'
]).
to
eq
(
2
)
...
@@ -140,14 +135,11 @@ shared_examples VulnerabilitiesActions do
...
@@ -140,14 +135,11 @@ shared_examples VulnerabilitiesActions do
context
'with enabled filters'
do
context
'with enabled filters'
do
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
%w[sast dast]
,
severity:
%[high low]
)
}
let
(
:params
)
{
vulnerable_params
.
merge
(
report_type:
%w[sast dast]
,
severity:
%[high low]
)
}
it
'returns counts for filtered vulnerabilities'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
200
)
it
'returns counts for filtered vulnerabilities'
do
expect
(
json_response
[
'high'
]).
to
eq
(
3
)
expect
(
json_response
[
'high'
]).
to
eq
(
3
)
expect
(
json_response
[
'low'
]).
to
eq
(
0
)
expect
(
json_response
[
'low'
]).
to
eq
(
0
)
expect
(
json_response
[
'medium'
]).
to
eq
(
2
)
expect
(
json_response
[
'medium'
]).
to
eq
(
2
)
expect
(
response
).
to
match_response_schema
(
'vulnerabilities/summary'
,
dir:
'ee'
)
end
end
end
end
end
end
...
@@ -202,7 +194,6 @@ shared_examples VulnerabilitiesActions do
...
@@ -202,7 +194,6 @@ shared_examples VulnerabilitiesActions do
subject
subject
end
end
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
).
to
eq
({
expect
(
json_response
).
to
eq
({
"undefined"
=>
{},
"undefined"
=>
{},
"info"
=>
{},
"info"
=>
{},
...
@@ -213,7 +204,6 @@ shared_examples VulnerabilitiesActions do
...
@@ -213,7 +204,6 @@ shared_examples VulnerabilitiesActions do
"critical"
=>
{},
"critical"
=>
{},
"total"
=>
{}
"total"
=>
{}
})
})
expect
(
response
).
to
match_response_schema
(
'vulnerabilities/history'
,
dir:
'ee'
)
end
end
context
'with a report type filter'
do
context
'with a report type filter'
do
...
@@ -224,11 +214,9 @@ shared_examples VulnerabilitiesActions do
...
@@ -224,11 +214,9 @@ shared_examples VulnerabilitiesActions do
subject
subject
end
end
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'total'
]).
to
eq
({
'2018-11-12'
=>
1
})
expect
(
json_response
[
'total'
]).
to
eq
({
'2018-11-12'
=>
1
})
expect
(
json_response
[
'critical'
]).
to
eq
({
'2018-11-12'
=>
1
})
expect
(
json_response
[
'critical'
]).
to
eq
({
'2018-11-12'
=>
1
})
expect
(
json_response
[
'low'
]).
to
eq
({})
expect
(
json_response
[
'low'
]).
to
eq
({})
expect
(
response
).
to
match_response_schema
(
'vulnerabilities/history'
,
dir:
'ee'
)
end
end
end
end
end
end
...
...
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