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
b3ad2f45
Commit
b3ad2f45
authored
Aug 14, 2019
by
Tetiana Chupryna
Committed by
Nick Thomas
Aug 14, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add dependency factory
Represent a dependency parsed from report
parent
af59919b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
63 deletions
+43
-63
ee/spec/factories/dependencies.rb
ee/spec/factories/dependencies.rb
+30
-0
ee/spec/serializers/dependency_entity_spec.rb
ee/spec/serializers/dependency_entity_spec.rb
+3
-27
ee/spec/serializers/dependency_list_entity_spec.rb
ee/spec/serializers/dependency_list_entity_spec.rb
+7
-17
ee/spec/serializers/dependency_list_serializer_spec.rb
ee/spec/serializers/dependency_list_serializer_spec.rb
+3
-19
No files found.
ee/spec/factories/dependencies.rb
0 → 100644
View file @
b3ad2f45
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:dependency
,
class:
Hash
do
name
'nokogiri'
packager
'Ruby (Bundler)'
version
'1.8.0'
location
do
{
blob_path:
'/some_project/path/Gemfile.lock'
,
path:
'Gemfile.lock'
}
end
trait
:with_vulnerabilities
do
vulnerabilities
do
[{
name:
'DDoS'
,
severity:
'high'
},
{
name:
'XSS vulnerability'
,
severity:
'low'
}]
end
end
initialize_with
{
attributes
}
end
end
ee/spec/serializers/dependency_entity_spec.rb
View file @
b3ad2f45
...
...
@@ -9,33 +9,7 @@ describe DependencyEntity do
set
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
set
(
:user
)
{
create
(
:user
)
}
let
(
:request
)
{
double
(
'request'
)
}
let
(
:dependency
)
{
dependency_info
.
merge
(
vulnerabilities
)
}
let
(
:dependency_info
)
do
{
name:
'nokogiri'
,
packager:
'Ruby (Bundler)'
,
version:
'1.8.0'
,
location:
{
blob_path:
'/some_project/path/Gemfile.lock'
,
path:
'Gemfile.lock'
}
}
end
let
(
:vulnerabilities
)
do
{
vulnerabilities:
[{
name:
'DDoS'
,
severity:
'high'
},
{
name:
'XSS vulnerability'
,
severity:
'low'
}]
}
end
let
(
:dependency
)
{
build
(
:dependency
,
:with_vulnerabilities
)
}
before
do
stub_licensed_features
(
security_dashboard:
true
)
...
...
@@ -54,6 +28,8 @@ describe DependencyEntity do
end
context
'with reporter'
do
let
(
:dependency_info
)
{
build
(
:dependency
)
}
before
do
project
.
add_reporter
(
user
)
end
...
...
ee/spec/serializers/dependency_list_entity_spec.rb
View file @
b3ad2f45
...
...
@@ -5,7 +5,7 @@ require 'spec_helper'
describe
DependencyListEntity
do
describe
'#as_json'
do
let
(
:entity
)
do
described_class
.
represent
(
dependencies
,
build:
build
,
request:
request
)
described_class
.
represent
(
dependencies
,
build:
ci_
build
,
request:
request
)
end
let
(
:request
)
{
double
(
'request'
)
}
...
...
@@ -22,23 +22,13 @@ describe DependencyListEntity do
context
'with success build'
do
let
(
:user
)
{
developer
}
let
(
:build
)
{
create
(
:ee_ci_build
,
:success
)
}
let
(
:
ci_
build
)
{
create
(
:ee_ci_build
,
:success
)
}
context
'with provided dependencies'
do
let
(
:dependencies
)
do
[{
name:
'nokogiri'
,
packager:
'Ruby (Bundler)'
,
version:
'1.8.0'
,
location:
{
blob_path:
'/some_project/path/Gemfile.lock'
,
path:
'Gemfile.lock'
}
}]
end
let
(
:dependencies
)
{
[
build
(
:dependency
)]
}
it
'has array of dependencies with status ok'
do
job_path
=
"/
#{
project
.
full_path
}
/builds/
#{
build
.
id
}
"
job_path
=
"/
#{
project
.
full_path
}
/builds/
#{
ci_
build
.
id
}
"
expect
(
subject
[
:dependencies
][
0
][
:name
]).
to
eq
(
'nokogiri'
)
expect
(
subject
[
:report
][
:status
]).
to
eq
(
:ok
)
...
...
@@ -51,7 +41,7 @@ describe DependencyListEntity do
let
(
:dependencies
)
{
[]
}
it
'has empty array of dependencies with status no_dependencies'
do
job_path
=
"/
#{
project
.
full_path
}
/builds/
#{
build
.
id
}
"
job_path
=
"/
#{
project
.
full_path
}
/builds/
#{
ci_
build
.
id
}
"
expect
(
subject
[
:dependencies
].
length
).
to
eq
(
0
)
expect
(
subject
[
:report
][
:status
]).
to
eq
(
:no_dependencies
)
...
...
@@ -61,7 +51,7 @@ describe DependencyListEntity do
end
context
'with failed build'
do
let
(
:build
)
{
create
(
:ee_ci_build
,
:failed
)
}
let
(
:
ci_
build
)
{
create
(
:ee_ci_build
,
:failed
)
}
let
(
:dependencies
)
{
[]
}
context
'with authorized user'
do
...
...
@@ -85,7 +75,7 @@ describe DependencyListEntity do
context
'with no build'
do
let
(
:user
)
{
developer
}
let
(
:build
)
{
nil
}
let
(
:
ci_
build
)
{
nil
}
let
(
:dependencies
)
{
[]
}
it
'has status job_not_set_up and no job_path'
do
...
...
ee/spec/serializers/dependency_list_serializer_spec.rb
View file @
b3ad2f45
...
...
@@ -3,29 +3,13 @@
require
'spec_helper'
describe
DependencyListSerializer
do
let
(
:build
)
{
create
(
:ee_ci_build
,
:success
)
}
set
(
:project
)
{
create
(
:project
,
:repository
,
:private
)
}
set
(
:user
)
{
create
(
:user
)
}
let
(
:ci_build
)
{
create
(
:ee_ci_build
,
:success
)
}
let
(
:dependencies
)
{
[
build
(
:dependency
,
:with_vulnerabilities
)]
}
let
(
:serializer
)
do
described_class
.
new
(
project:
project
,
user:
user
).
represent
(
dependencies
,
build:
build
)
end
let
(
:dependencies
)
do
[{
name:
'nokogiri'
,
packager:
'Ruby (Bundler)'
,
version:
'1.8.0'
,
location:
{
blob_path:
'/some_project/path/Gemfile.lock'
,
path:
'Gemfile.lock'
},
vulnerabilities:
[{
name:
'XSS'
,
severity:
'low'
}]
}]
described_class
.
new
(
project:
project
,
user:
user
).
represent
(
dependencies
,
build:
ci_build
)
end
before
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