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
ebe40f45
Commit
ebe40f45
authored
Apr 07, 2021
by
Mehmet Emin INAC
Committed by
Luke Duncalfe
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix `errors` attribute of ScanType on GraphQL
parent
09580cb6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
4 deletions
+66
-4
ee/app/graphql/types/scan_type.rb
ee/app/graphql/types/scan_type.rb
+2
-4
ee/app/presenters/security/scan_presenter.rb
ee/app/presenters/security/scan_presenter.rb
+13
-0
ee/changelogs/unreleased/fix_scan_errors_on_graphql_api.yml
ee/changelogs/unreleased/fix_scan_errors_on_graphql_api.yml
+5
-0
ee/spec/graphql/types/scan_type_spec.rb
ee/spec/graphql/types/scan_type_spec.rb
+32
-0
ee/spec/presenters/security/scan_presenter_spec.rb
ee/spec/presenters/security/scan_presenter_spec.rb
+14
-0
No files found.
ee/app/graphql/types/scan_type.rb
View file @
ebe40f45
...
...
@@ -3,6 +3,8 @@
module
Types
# rubocop: disable Graphql/AuthorizeTypes
class
ScanType
<
BaseObject
present_using
::
Security
::
ScanPresenter
graphql_name
'Scan'
description
'Represents the security scan information'
...
...
@@ -10,9 +12,5 @@ module Types
field
:name
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'Name of the scan.'
field
:errors
,
[
GraphQL
::
STRING_TYPE
],
null:
false
,
description:
'List of errors.'
def
errors
object
.
info
[
'errors'
].
to_a
end
end
end
ee/app/presenters/security/scan_presenter.rb
0 → 100644
View file @
ebe40f45
# frozen_string_literal: true
module
Security
class
ScanPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
ERROR_MESSAGE_FORMAT
=
'[%<type>s] %<message>s'
presents
:scan
def
errors
info
[
'errors'
].
to_a
.
map
{
|
error
|
format
(
ERROR_MESSAGE_FORMAT
,
error
.
symbolize_keys
)
}
end
end
end
ee/changelogs/unreleased/fix_scan_errors_on_graphql_api.yml
0 → 100644
View file @
ebe40f45
---
title
:
Fix the 'errors' attribute of the 'ScanType' on GraphQL API
merge_request
:
57882
author
:
type
:
fixed
ee/spec/graphql/types/scan_type_spec.rb
View file @
ebe40f45
...
...
@@ -3,8 +3,40 @@
require
'spec_helper'
RSpec
.
describe
GitlabSchema
.
types
[
'Scan'
]
do
include
GraphqlHelpers
let
(
:fields
)
{
%i(name errors)
}
it
{
expect
(
described_class
).
to
have_graphql_fields
(
fields
)
}
it
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:read_scan
)
}
describe
'field values'
do
let_it_be
(
:build
)
{
create
(
:ee_ci_build
,
:dast
,
name:
'foo'
)
}
let_it_be
(
:security_scan
)
{
build
.
security_scans
.
first
}
let_it_be
(
:user
)
{
create
(
:user
)
}
subject
{
resolve_field
(
field_name
,
security_scan
,
current_user:
user
)
}
before
do
stub_licensed_features
(
security_dashboard:
true
)
build
.
project
.
add_developer
(
user
)
end
describe
'name'
do
let
(
:field_name
)
{
:name
}
it
{
is_expected
.
to
eq
(
'foo'
)
}
end
describe
'errors'
do
let
(
:field_name
)
{
:errors
}
before
do
security_scan
.
update!
(
info:
{
'errors'
=>
[{
'type'
=>
'foo'
,
'message'
=>
'bar'
}]
})
end
it
{
is_expected
.
to
eq
([
'[foo] bar'
])
}
end
end
end
ee/spec/presenters/security/scan_presenter_spec.rb
0 → 100644
View file @
ebe40f45
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Security
::
ScanPresenter
do
let
(
:presenter
)
{
described_class
.
new
(
security_scan
)
}
let
(
:security_scan
)
{
build_stubbed
(
:security_scan
,
info:
{
'errors'
=>
[{
'type'
=>
'foo'
,
'message'
=>
'bar'
}]
})
}
describe
'#errors'
do
subject
{
presenter
.
errors
}
it
{
is_expected
.
to
eq
([
'[foo] bar'
])
}
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