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
f52c68e4
Commit
f52c68e4
authored
Jan 06, 2021
by
Saikat Sarkar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase test coverage for vulnerability_presenter
parent
d9252c0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
3 deletions
+58
-3
ee/spec/presenters/vulnerability_presenter_spec.rb
ee/spec/presenters/vulnerability_presenter_spec.rb
+58
-3
No files found.
ee/spec/presenters/vulnerability_presenter_spec.rb
View file @
f52c68e4
...
@@ -3,9 +3,14 @@
...
@@ -3,9 +3,14 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
VulnerabilityPresenter
do
RSpec
.
describe
VulnerabilityPresenter
do
let
(
:project
)
{
create
(
:project
)
}
let_it_be
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
let_it_be
(
:pipeline
)
{
create
(
:ci_pipeline
,
:success
,
project:
project
)
}
let
(
:finding
)
{
create
(
:vulnerabilities_finding
,
:with_secret_detection
,
pipelines:
[
pipeline
],
project:
project
)
}
let_it_be
(
:sast_scan
)
do
{
type:
'sast'
,
status:
'success'
,
start_time:
'placeholder'
,
end_time:
'placeholder'
}
end
let_it_be
(
:finding
)
{
create
(
:vulnerabilities_finding
,
:with_secret_detection
,
pipelines:
[
pipeline
],
project:
project
)
}
let_it_be
(
:finding2
)
{
create
(
:vulnerabilities_finding
,
:with_secret_detection
,
scan:
sast_scan
)
}
subject
{
described_class
.
new
(
finding
.
vulnerability
)
}
subject
{
described_class
.
new
(
finding
.
vulnerability
)
}
...
@@ -13,6 +18,24 @@ RSpec.describe VulnerabilityPresenter do
...
@@ -13,6 +18,24 @@ RSpec.describe VulnerabilityPresenter do
it
'returns the scanner for a finding'
do
it
'returns the scanner for a finding'
do
expect
(
subject
.
scanner
).
to
eql
(
finding
.
scanner
)
expect
(
subject
.
scanner
).
to
eql
(
finding
.
scanner
)
end
end
it
'returns empty hash if scanner is missing for a vulnerabilities_finding'
do
finding2
.
scanner
=
nil
expect
(
described_class
.
new
(
finding2
.
vulnerability
).
scanner
).
to
eql
({})
end
end
describe
'#scan'
do
it
'returns the scan for a finding'
do
expect
(
described_class
.
new
(
finding2
.
vulnerability
).
scan
).
to
eql
(
finding2
.
scan
)
end
it
'returns empty hash if scan is missing for a vulnerabilities_finding'
do
finding2
.
scan
=
nil
expect
(
described_class
.
new
(
finding2
.
vulnerability
).
scan
).
to
eql
({})
end
end
end
describe
'#remediations'
do
describe
'#remediations'
do
...
@@ -43,6 +66,38 @@ RSpec.describe VulnerabilityPresenter do
...
@@ -43,6 +66,38 @@ RSpec.describe VulnerabilityPresenter do
end
end
end
end
describe
'#blob_path'
do
it
'returns the path in blob format'
do
path
=
subject
.
blob_path
expect
(
path
).
to
include
(
'blob'
)
expect
(
path
).
to
include
(
finding
.
file
)
expect
(
path
).
to
include
(
"#L
#{
finding
.
location
[
'start_line'
]
}
"
)
end
it
'returns nil if file is missing in the finding'
do
allow
(
subject
).
to
receive
(
:file
).
and_return
(
nil
)
expect
(
subject
.
blob_path
).
to
be
(
nil
)
end
end
describe
'#raw_path'
do
it
'returns the path in raw format'
do
path
=
subject
.
raw_path
expect
(
path
).
to
include
(
'raw'
)
expect
(
path
).
to
include
(
finding
.
file
)
expect
(
path
).
to
include
(
"#L
#{
finding
.
location
[
'start_line'
]
}
"
)
end
it
'returns nil if file is missing in the finding'
do
allow
(
subject
).
to
receive
(
:file
).
and_return
(
nil
)
expect
(
subject
.
raw_path
).
to
be
(
nil
)
end
end
describe
'#jira_issue_description'
do
describe
'#jira_issue_description'
do
let
(
:expected_jira_issue_description
)
do
let
(
:expected_jira_issue_description
)
do
<<-
JIRA
.
strip_heredoc
<<-
JIRA
.
strip_heredoc
...
...
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