Commit 656985bf authored by Grzegorz Bizon's avatar Grzegorz Bizon

Make authentication metrics events explicit is specs

parent 0da5c588
...@@ -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_signed_out! Gitlab::Auth::Activity.new(user, opts).user_session_destroyed!
end end
end end
...@@ -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_signed_out! def user_session_destroyed!
self.class.user_signed_out_counter_increment! self.class.user_session_destroyed_counter_increment!
end end
def self.each_counter def self.each_counter
......
This diff is collapsed.
...@@ -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
......
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment