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
24f3ef5c
Commit
24f3ef5c
authored
Jan 30, 2020
by
Sean Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add authorisation for SentryErrorStackTraceType
- Stylistic changes
parent
d3267254
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
36 deletions
+37
-36
app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb
...lvers/error_tracking/sentry_error_stack_trace_resolver.rb
+0
-1
app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb
...hql/types/error_tracking/sentry_error_stack_trace_type.rb
+2
-2
spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb
...types/error_tracking/sentry_error_collection_type_spec.rb
+1
-1
spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb
...ypes/error_tracking/sentry_error_stack_trace_type_spec.rb
+2
-0
spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb
...phql/project/error_tracking/sentry_errors_request_spec.rb
+20
-20
spec/support/shared_examples/error_tracking_shared_examples.rb
...support/shared_examples/error_tracking_shared_examples.rb
+12
-12
No files found.
app/graphql/resolvers/error_tracking/sentry_error_stack_trace_resolver.rb
View file @
24f3ef5c
...
...
@@ -8,7 +8,6 @@ module Resolvers
description:
'ID of the Sentry issue'
def
resolve
(
**
args
)
current_user
=
context
[
:current_user
]
issue_id
=
GlobalID
.
parse
(
args
[
:id
]).
model_id
# Get data from Sentry
...
...
app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb
View file @
24f3ef5c
...
...
@@ -2,11 +2,12 @@
module
Types
module
ErrorTracking
# rubocop: disable Graphql/AuthorizeTypes
class
SentryErrorStackTraceType
<
::
Types
::
BaseObject
graphql_name
'SentryErrorStackTrace'
description
'An object containing a stack trace entry for a Sentry error.'
authorize
:read_sentry_issue
field
:issue_id
,
GraphQL
::
STRING_TYPE
,
null:
false
,
description:
'ID of the Sentry error'
...
...
@@ -17,6 +18,5 @@ module Types
null:
false
,
description:
'Stack trace entries for the Sentry error'
end
# rubocop: enable Graphql/AuthorizeTypes
end
end
spec/graphql/types/error_tracking/sentry_error_collection_type_spec.rb
View file @
24f3ef5c
...
...
@@ -12,7 +12,7 @@ describe GitlabSchema.types['SentryErrorCollection'] do
errors
detailed_error
external_url
error
StackT
race
error
_stack_t
race
]
is_expected
.
to
have_graphql_fields
(
*
expected_fields
)
...
...
spec/graphql/types/error_tracking/sentry_error_stack_trace_type_spec.rb
View file @
24f3ef5c
...
...
@@ -5,6 +5,8 @@ require 'spec_helper'
describe
GitlabSchema
.
types
[
'SentryErrorStackTrace'
]
do
it
{
expect
(
described_class
.
graphql_name
).
to
eq
(
'SentryErrorStackTrace'
)
}
it
{
expect
(
described_class
).
to
require_graphql_authorizations
(
:read_sentry_issue
)
}
it
'exposes the expected fields'
do
expected_fields
=
%i[
issue_id
...
...
spec/requests/api/graphql/project/error_tracking/sentry_errors_request_spec.rb
View file @
24f3ef5c
...
...
@@ -40,8 +40,8 @@ describe 'sentry errors requests' do
post_graphql
(
query
,
current_user:
current_user
)
end
it
"is expected to return an empty error"
do
expect
(
error_data
).
to
eq
nil
it
'is expected to return an empty error'
do
expect
(
error_data
).
to
be_
nil
end
end
...
...
@@ -49,7 +49,7 @@ describe 'sentry errors requests' do
before
do
allow_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:issue_details
)
.
and_return
(
{
issue:
sentry_detailed_error
}
)
.
and_return
(
issue:
sentry_detailed_error
)
post_graphql
(
query
,
current_user:
current_user
)
end
...
...
@@ -72,8 +72,8 @@ describe 'sentry errors requests' do
context
'user does not have permission'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
"is expected to return an empty error"
do
expect
(
error_data
).
to
eq
nil
it
'is expected to return an empty error'
do
expect
(
error_data
).
to
be_
nil
end
end
end
...
...
@@ -82,13 +82,13 @@ describe 'sentry errors requests' do
before
do
expect_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:issue_details
)
.
and_return
(
{
error:
'error message'
}
)
.
and_return
(
error:
'error message'
)
post_graphql
(
query
,
current_user:
current_user
)
end
it
'is expected to handle the error and return nil'
do
expect
(
error_data
).
to
eq
nil
expect
(
error_data
).
to
be_
nil
end
end
end
...
...
@@ -132,8 +132,8 @@ describe 'sentry errors requests' do
post_graphql
(
query
,
current_user:
current_user
)
end
it
"is expected to return nil"
do
expect
(
error_data
).
to
eq
nil
it
'is expected to return nil'
do
expect
(
error_data
).
to
be_
nil
end
end
...
...
@@ -141,7 +141,7 @@ describe 'sentry errors requests' do
before
do
expect_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:list_sentry_issues
)
.
and_return
(
{
issues:
[
sentry_error
],
pagination:
pagination
}
)
.
and_return
(
issues:
[
sentry_error
],
pagination:
pagination
)
post_graphql
(
query
,
current_user:
current_user
)
end
...
...
@@ -174,17 +174,17 @@ describe 'sentry errors requests' do
end
end
context
"sentry api itself errors out"
do
context
'sentry api itself errors out'
do
before
do
expect_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:list_sentry_issues
)
.
and_return
(
{
error:
'error message'
}
)
.
and_return
(
error:
'error message'
)
post_graphql
(
query
,
current_user:
current_user
)
end
it
'is expected to handle the error and return nil'
do
expect
(
error_data
).
to
eq
nil
expect
(
error_data
).
to
be_
nil
end
end
end
...
...
@@ -214,8 +214,8 @@ describe 'sentry errors requests' do
post_graphql
(
query
,
current_user:
current_user
)
end
it
"is expected to return an empty error"
do
expect
(
stack_trace_data
).
to
eq
nil
it
'is expected to return an empty error'
do
expect
(
stack_trace_data
).
to
be_
nil
end
end
...
...
@@ -223,7 +223,7 @@ describe 'sentry errors requests' do
before
do
allow_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:issue_latest_event
)
.
and_return
(
{
latest_event:
sentry_stack_trace
}
)
.
and_return
(
latest_event:
sentry_stack_trace
)
post_graphql
(
query
,
current_user:
current_user
)
end
...
...
@@ -233,8 +233,8 @@ describe 'sentry errors requests' do
context
'user does not have permission'
do
let
(
:current_user
)
{
create
(
:user
)
}
it
"is expected to return an empty error"
do
expect
(
stack_trace_data
).
to
eq
nil
it
'is expected to return an empty error'
do
expect
(
stack_trace_data
).
to
be_
nil
end
end
end
...
...
@@ -243,13 +243,13 @@ describe 'sentry errors requests' do
before
do
expect_any_instance_of
(
ErrorTracking
::
ProjectErrorTrackingSetting
)
.
to
receive
(
:issue_latest_event
)
.
and_return
(
{
error:
'error message'
}
)
.
and_return
(
error:
'error message'
)
post_graphql
(
query
,
current_user:
current_user
)
end
it
'is expected to handle the error and return nil'
do
expect
(
stack_trace_data
).
to
eq
nil
expect
(
stack_trace_data
).
to
be_
nil
end
end
end
...
...
spec/support/shared_examples/error_tracking_shared_examples.rb
View file @
24f3ef5c
...
...
@@ -3,11 +3,11 @@
RSpec
.
shared_examples
'setting sentry error data'
do
it
'sets the sentry error data correctly'
do
aggregate_failures
'testing the sentry error is correct'
do
expect
(
error
[
'id'
]).
to
eq
l
sentry_error
.
to_global_id
.
to_s
expect
(
error
[
'sentryId'
]).
to
eq
l
sentry_error
.
id
.
to_s
expect
(
error
[
'status'
]).
to
eq
l
sentry_error
.
status
.
upcase
expect
(
error
[
'firstSeen'
]).
to
eq
l
sentry_error
.
first_seen
expect
(
error
[
'lastSeen'
]).
to
eq
l
sentry_error
.
last_seen
expect
(
error
[
'id'
]).
to
eq
sentry_error
.
to_global_id
.
to_s
expect
(
error
[
'sentryId'
]).
to
eq
sentry_error
.
id
.
to_s
expect
(
error
[
'status'
]).
to
eq
sentry_error
.
status
.
upcase
expect
(
error
[
'firstSeen'
]).
to
eq
sentry_error
.
first_seen
expect
(
error
[
'lastSeen'
]).
to
eq
sentry_error
.
last_seen
end
end
end
...
...
@@ -15,10 +15,10 @@ end
RSpec
.
shared_examples
'setting stack trace error'
do
it
'sets the stack trace data correctly'
do
aggregate_failures
'testing the stack trace is correct'
do
expect
(
stack_trace_data
[
'dateReceived'
]).
to
eq
l
(
sentry_stack_trace
.
date_received
)
expect
(
stack_trace_data
[
'issueId'
]).
to
eq
l
(
sentry_stack_trace
.
issue_id
)
expect
(
stack_trace_data
[
'dateReceived'
]).
to
eq
(
sentry_stack_trace
.
date_received
)
expect
(
stack_trace_data
[
'issueId'
]).
to
eq
(
sentry_stack_trace
.
issue_id
)
expect
(
stack_trace_data
[
'stackTraceEntries'
]).
to
be_an_instance_of
(
Array
)
expect
(
stack_trace_data
[
'stackTraceEntries'
].
size
).
to
eq
l
(
sentry_stack_trace
.
stack_trace_entries
.
size
)
expect
(
stack_trace_data
[
'stackTraceEntries'
].
size
).
to
eq
(
sentry_stack_trace
.
stack_trace_entries
.
size
)
end
end
...
...
@@ -27,10 +27,10 @@ RSpec.shared_examples 'setting stack trace error' do
stack_trace_entry
=
stack_trace_data
[
'stackTraceEntries'
].
first
model_entry
=
sentry_stack_trace
.
stack_trace_entries
.
first
expect
(
stack_trace_entry
[
'function'
]).
to
eq
l
model_entry
[
'function'
]
expect
(
stack_trace_entry
[
'col'
]).
to
eq
l
model_entry
[
'colNo'
]
expect
(
stack_trace_entry
[
'line'
]).
to
eq
l
model_entry
[
'lineNo'
].
to_s
expect
(
stack_trace_entry
[
'fileName'
]).
to
eq
l
model_entry
[
'filename'
]
expect
(
stack_trace_entry
[
'function'
]).
to
eq
model_entry
[
'function'
]
expect
(
stack_trace_entry
[
'col'
]).
to
eq
model_entry
[
'colNo'
]
expect
(
stack_trace_entry
[
'line'
]).
to
eq
model_entry
[
'lineNo'
].
to_s
expect
(
stack_trace_entry
[
'fileName'
]).
to
eq
model_entry
[
'filename'
]
end
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