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
fbe19e65
Commit
fbe19e65
authored
6 years ago
by
Tetiana Chupryna
Committed by
Kamil Trzciński
6 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for Gitlab::Vulnerabilities classes
parent
c2a2b45d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
0 deletions
+92
-0
ee/spec/lib/gitlab/vulnerabilities/base_vulnerability_spec.rb
...pec/lib/gitlab/vulnerabilities/base_vulnerability_spec.rb
+27
-0
ee/spec/lib/gitlab/vulnerabilities/container_scanning_vulnerability_spec.rb
.../vulnerabilities/container_scanning_vulnerability_spec.rb
+65
-0
No files found.
ee/spec/lib/gitlab/vulnerabilities/base_vulnerability_spec.rb
0 → 100644
View file @
fbe19e65
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Vulnerabilities
::
BaseVulnerability
do
let
(
:vulnerability
)
do
described_class
.
new
(
title:
'title'
,
description:
'desc'
,
severity:
'high'
,
confidence:
'low'
,
solution:
'fix'
,
identifiers:
'42'
,
links:
'link'
)
end
where
(
:getter
)
do
%w(title description severity confidence solution identifiers links)
end
with_them
do
it
'raises an error'
do
expect
{
vulnerability
.
public_send
(
getter
)
}.
to
raise_error
(
NotImplementedError
)
end
end
end
This diff is collapsed.
Click to expand it.
ee/spec/lib/gitlab/vulnerabilities/container_scanning_vulnerability_spec.rb
0 → 100644
View file @
fbe19e65
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Vulnerabilities
::
ContainerScanningVulnerability
do
let
(
:vulnerability
)
{
described_class
.
new
(
data
)
}
let
(
:data
)
do
{
vulnerability:
'vulnerability'
,
namespace:
'namespace'
,
description:
'desc'
,
severity:
'high'
,
confidence:
'low'
,
identifiers:
'42'
,
links:
'link'
}
end
where
(
:getter
)
do
%i(description severity confidence solution identifiers links)
end
with_them
do
it
'returns right value'
do
expect
(
vulnerability
.
public_send
(
getter
)).
to
eq
(
data
[
getter
])
end
end
describe
'#title'
do
it
'composes properly'
do
expect
(
vulnerability
.
title
).
to
eq
(
'vulnerability in namespace'
)
end
end
describe
'#description'
do
context
'without description param'
do
let
(
:vulnerability
)
{
described_class
.
new
(
data
.
without
(
:description
))
}
subject
{
vulnerability
.
description
}
it
'returns composed description'
do
is_expected
.
to
eq
(
'**namespace** is affected by vulnerability'
)
end
end
describe
'#solution'
do
context
'without needed params'
do
it
'returns empty solution'
do
expect
(
vulnerability
.
solution
).
to
be_nil
end
end
context
'with all params'
do
let
(
:vulnerability
)
{
described_class
.
new
(
fixedby:
'eleven'
,
featurename:
'tardis'
,
featureversion:
'ten'
)
}
subject
{
vulnerability
.
solution
}
it
'composes properly'
do
is_expected
.
to
eq
(
'Upgrade **tardis** from `ten` to `eleven`'
)
end
end
end
end
end
This diff is collapsed.
Click to expand it.
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