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
76cb7e5f
Commit
76cb7e5f
authored
Mar 27, 2020
by
Can Eldem
Committed by
Heinrich Lee Yu
Mar 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor compare analyser reports service tests
parent
4629e944
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
27 deletions
+18
-27
ee/spec/services/ci/compare_container_scanning_reports_service_spec.rb
...ces/ci/compare_container_scanning_reports_service_spec.rb
+2
-19
ee/spec/services/ci/compare_dast_reports_service_spec.rb
ee/spec/services/ci/compare_dast_reports_service_spec.rb
+2
-2
ee/spec/services/ci/compare_dependency_scanning_reports_service_spec.rb
...es/ci/compare_dependency_scanning_reports_service_spec.rb
+11
-4
ee/spec/services/ci/compare_sast_reports_service_spec.rb
ee/spec/services/ci/compare_sast_reports_service_spec.rb
+3
-2
No files found.
ee/spec/services/ci/compare_container_scanning_reports_service_spec.rb
View file @
76cb7e5f
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
describe
Ci
::
CompareContainerScanningReportsService
do
let
(
:current_user
)
{
project
.
users
.
take
}
let
(
:current_user
)
{
build
(
:user
,
:admin
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
build
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
container_scanning:
true
)
...
...
@@ -59,22 +59,5 @@ describe Ci::CompareContainerScanningReportsService do
expect
(
compare_keys
-
expected_keys
).
to
eq
([])
end
end
context
'when head pipeline has corrupted container scanning vulnerability reports'
do
let!
(
:base_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_container_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_container_scanning_report
,
project:
project
)
}
it
'returns status and error message'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
expect
(
subject
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
it
'returns status and error message when pipeline is nil'
do
result
=
service
.
execute
(
nil
,
head_pipeline
)
expect
(
result
[
:status
]).
to
eq
(
:error
)
expect
(
result
[
:status_reason
]).
to
include
(
'JSON parsing failed'
)
end
end
end
end
ee/spec/services/ci/compare_dast_reports_service_spec.rb
View file @
76cb7e5f
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
describe
Ci
::
CompareDastReportsService
do
let
(
:current_user
)
{
project
.
users
.
take
}
let
(
:current_user
)
{
build
(
:user
,
:admin
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
build
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
container_scanning:
true
,
dast:
true
)
...
...
ee/spec/services/ci/compare_dependency_scanning_reports_service_spec.rb
View file @
76cb7e5f
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
describe
Ci
::
CompareDependencyScanningReportsService
do
let
(
:current_user
)
{
project
.
users
.
take
}
let
(
:current_user
)
{
build
(
:user
,
:admin
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
build
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
dependency_scanning:
true
)
...
...
@@ -36,6 +36,7 @@ describe Ci::CompareDependencyScanningReportsService do
it
'populates fields based on current_user'
do
payload
=
subject
[
:data
][
'existing'
].
first
expect
(
payload
[
'create_vulnerability_feedback_issue_path'
]).
not_to
be_empty
expect
(
payload
[
'create_vulnerability_feedback_merge_request_path'
]).
not_to
be_empty
expect
(
payload
[
'create_vulnerability_feedback_dismissal_path'
]).
not_to
be_empty
...
...
@@ -61,8 +62,14 @@ describe Ci::CompareDependencyScanningReportsService do
end
context
'when head pipeline has corrupted dependency scanning vulnerability reports'
do
let!
(
:base_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
create
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
let!
(
:base_pipeline
)
{
build
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
let!
(
:head_pipeline
)
{
build
(
:ee_ci_pipeline
,
:with_corrupted_dependency_scanning_report
,
project:
project
)
}
before
do
error
=
Gitlab
::
Ci
::
Parsers
::
ParserError
.
new
(
'Exception: JSON parsing failed'
)
allow
(
base_pipeline
).
to
receive
(
:license_scanning_report
).
and_raise
(
error
)
allow
(
head_pipeline
).
to
receive
(
:license_scanning_report
).
and_raise
(
error
)
end
it
'returns status and error message'
do
expect
(
subject
[
:status
]).
to
eq
(
:error
)
...
...
ee/spec/services/ci/compare_sast_reports_service_spec.rb
View file @
76cb7e5f
...
...
@@ -3,9 +3,9 @@
require
'spec_helper'
describe
Ci
::
CompareSastReportsService
do
let
(
:current_user
)
{
project
.
users
.
take
}
let
(
:current_user
)
{
build
(
:user
,
:admin
)
}
let
(
:service
)
{
described_class
.
new
(
project
,
current_user
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
build
(
:project
,
:repository
)
}
before
do
stub_licensed_features
(
container_scanning:
true
)
...
...
@@ -37,6 +37,7 @@ describe Ci::CompareSastReportsService do
it
'populates fields based on current_user'
do
payload
=
subject
[
:data
][
'existing'
].
first
expect
(
payload
[
'create_vulnerability_feedback_issue_path'
]).
not_to
be_empty
expect
(
payload
[
'create_vulnerability_feedback_merge_request_path'
]).
not_to
be_empty
expect
(
payload
[
'create_vulnerability_feedback_dismissal_path'
]).
not_to
be_empty
...
...
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