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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
656985bf
Commit
656985bf
authored
Jul 26, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make authentication metrics events explicit is specs
parent
0da5c588
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
180 additions
and
31 deletions
+180
-31
config/initializers/warden.rb
config/initializers/warden.rb
+1
-1
lib/gitlab/auth/activity.rb
lib/gitlab/auth/activity.rb
+4
-4
spec/features/users/login_spec.rb
spec/features/users/login_spec.rb
+168
-24
spec/support/helpers/stub_metrics.rb
spec/support/helpers/stub_metrics.rb
+0
-1
spec/support/prometheus/custom_matchers.rb
spec/support/prometheus/custom_matchers.rb
+7
-1
No files found.
config/initializers/warden.rb
View file @
656985bf
...
@@ -28,6 +28,6 @@ Rails.application.configure do |config|
...
@@ -28,6 +28,6 @@ Rails.application.configure do |config|
user
=
user_warden
||
auth
.
user
user
=
user_warden
||
auth
.
user
ActiveSession
.
destroy
(
user
,
auth
.
request
.
session
.
id
)
ActiveSession
.
destroy
(
user
,
auth
.
request
.
session
.
id
)
Gitlab
::
Auth
::
Activity
.
new
(
user
,
opts
).
user_s
igned_out
!
Gitlab
::
Auth
::
Activity
.
new
(
user
,
opts
).
user_s
ession_destroyed
!
end
end
end
end
lib/gitlab/auth/activity.rb
View file @
656985bf
...
@@ -12,9 +12,9 @@ module Gitlab
...
@@ -12,9 +12,9 @@ module Gitlab
user_not_found:
'Counter of total failed log-ins when user is unknown'
,
user_not_found:
'Counter of total failed log-ins when user is unknown'
,
user_password_invalid:
'Counter of failed log-ins with invalid password'
,
user_password_invalid:
'Counter of failed log-ins with invalid password'
,
user_session_override:
'Counter of manual log-ins and sessions overrides'
,
user_session_override:
'Counter of manual log-ins and sessions overrides'
,
user_session_destroyed:
'Counter of total user sessions being destroyed'
,
user_two_factor_authenticated:
'Counter of two factor authentications'
,
user_two_factor_authenticated:
'Counter of two factor authentications'
,
user_blocked:
'Counter of total sign in attempts when user is blocked'
,
user_blocked:
'Counter of total sign in attempts when user is blocked'
user_signed_out:
'Counter of total user sign out events'
}.
freeze
}.
freeze
def
initialize
(
user
,
opts
)
def
initialize
(
user
,
opts
)
...
@@ -50,8 +50,8 @@ module Gitlab
...
@@ -50,8 +50,8 @@ module Gitlab
end
end
end
end
def
user_s
igned_out
!
def
user_s
ession_destroyed
!
self
.
class
.
user_s
igned_out
_counter_increment!
self
.
class
.
user_s
ession_destroyed
_counter_increment!
end
end
def
self
.
each_counter
def
self
.
each_counter
...
...
spec/features/users/login_spec.rb
View file @
656985bf
This diff is collapsed.
Click to expand it.
spec/support/helpers/stub_metrics.rb
View file @
656985bf
...
@@ -7,7 +7,6 @@ module StubMetrics
...
@@ -7,7 +7,6 @@ module StubMetrics
authentication_metrics
.
each_counter
do
|
name
,
metric
,
description
|
authentication_metrics
.
each_counter
do
|
name
,
metric
,
description
|
double
(
"
#{
metric
}
-
#{
description
}
"
).
tap
do
|
counter
|
double
(
"
#{
metric
}
-
#{
description
}
"
).
tap
do
|
counter
|
allow
(
authentication_metrics
).
to
receive
(
name
).
and_return
(
counter
)
allow
(
authentication_metrics
).
to
receive
(
name
).
and_return
(
counter
)
allow
(
counter
).
to
receive
(
:increment
)
# TODO, require expectations
end
end
end
end
...
...
spec/support/prometheus/custom_matchers.rb
View file @
656985bf
RSpec
::
Matchers
.
define
:increment
do
|
counter
|
RSpec
::
Matchers
.
define
:increment
do
|
counter
|
match
do
|
adapter
|
match
do
|
adapter
|
expect
(
adapter
.
send
(
counter
)).
to
receive
(
:increment
)
expect
(
adapter
.
send
(
counter
))
.
to
receive
(
:increment
)
.
exactly
(
@exactly
||
:once
)
end
chain
:twice
do
@exactly
=
:twice
end
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