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
140b5493
Commit
140b5493
authored
Nov 17, 2021
by
Manoj M J
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify exception logging in U2fRegistration’s callback
This MR modifies exception logging in U2fRegistration’s callback
parent
38bbc861
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
app/models/u2f_registration.rb
app/models/u2f_registration.rb
+1
-5
spec/models/u2f_registration_spec.rb
spec/models/u2f_registration_spec.rb
+11
-8
No files found.
app/models/u2f_registration.rb
View file @
140b5493
...
...
@@ -12,11 +12,7 @@ class U2fRegistration < ApplicationRecord
converter
=
Gitlab
::
Auth
::
U2fWebauthnConverter
.
new
(
self
)
WebauthnRegistration
.
create!
(
converter
.
convert
)
rescue
StandardError
=>
ex
Gitlab
::
AppJsonLogger
.
error
(
event:
'u2f_migration'
,
error:
ex
.
class
.
name
,
backtrace:
::
Gitlab
::
BacktraceCleaner
.
clean_backtrace
(
ex
.
backtrace
),
message:
"U2F to WebAuthn conversion failed"
)
Gitlab
::
ErrorTracking
.
track_exception
(
ex
,
u2f_registration_id:
self
.
id
)
end
def
update_webauthn_registration
...
...
spec/models/u2f_registration_spec.rb
View file @
140b5493
...
...
@@ -20,9 +20,9 @@ RSpec.describe U2fRegistration do
describe
'#create_webauthn_registration'
do
shared_examples_for
'creates webauthn registration'
do
it
'creates webauthn registration'
do
u2f_registration
.
save!
created_record
=
u2f_registration
webauthn_registration
=
WebauthnRegistration
.
where
(
u2f_registration_id:
u2f_registration
.
id
)
webauthn_registration
=
WebauthnRegistration
.
where
(
u2f_registration_id:
created_record
.
id
)
expect
(
webauthn_registration
).
to
exist
end
end
...
...
@@ -43,13 +43,16 @@ RSpec.describe U2fRegistration do
it
'logs error'
do
allow
(
Gitlab
::
Auth
::
U2fWebauthnConverter
).
to
receive
(
:new
).
and_raise
(
'boom!'
)
expect
(
Gitlab
::
AppJsonLogger
).
to
(
receive
(
:error
).
with
(
a_hash_including
(
event:
'u2f_migration'
,
error:
'RuntimeError'
,
message:
'U2F to WebAuthn conversion failed'
))
)
u2f_registration
.
save!
allow_next_instance_of
(
U2fRegistration
)
do
|
u2f_registration
|
allow
(
u2f_registration
).
to
receive
(
:id
).
and_return
(
123
)
end
expect
(
Gitlab
::
ErrorTracking
).
to
(
receive
(
:track_exception
).
with
(
kind_of
(
StandardError
),
u2f_registration_id:
123
))
u2f_registration
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