Commit ac4b954c authored by Grzegorz Bizon's avatar Grzegorz Bizon

Rename authentication activity observer methods

parent 41607661
......@@ -22,12 +22,12 @@ Rails.application.configure do |config|
end
Warden::Manager.after_set_user(scope: :user, only: :set_user) do |user, auth, opts|
Gitlab::Auth::Activity.new(opts).user_set_manually!
Gitlab::Auth::Activity.new(opts).user_session_override!
end
Warden::Manager.before_logout(scope: :user) do |user, auth, opts|
ActiveSession.destroy(user || auth.user, auth.request.session.id)
Gitlab::Auth::Activity.new(opts).user_logout!
Gitlab::Auth::Activity.new(opts).user_signed_out!
end
end
......@@ -39,28 +39,18 @@ module Gitlab
self.class.user_session_fetched_counter.increment
end
def user_set_manually!
def user_session_override!
self.class.user_session_override_counter.increment
end
def user_logout!
def user_signed_out!
self.class.user_signed_out_counter.increment
end
class StubCounter
def initialize(metric)
Rails.logger.warn("METRIC #{metric}")
end
def increment
end
end
COUNTERS.each_pair do |metric, description|
define_singleton_method("#{metric}_counter") do
strong_memoize(metric) do
StubCounter.new(metric)
# Gitlab::Metrics.counter("gitlab_auth_#{metric}_total", description)
Gitlab::Metrics.counter("gitlab_auth_#{metric}_total".to_sym, description)
end
end
end
......
......@@ -29,6 +29,7 @@ describe 'Login' do
User.delete_all
user = create(:admin, password_automatically_set: true)
expect(Gitlab::Auth::Activity).to increment(:user_authenticated_counter)
visit root_path
expect(current_path).to eq edit_user_password_path
......
RSpec::Matchers.define :increment do |counter|
match do |metric|
expect(metric.send(counter)).to receive(:increment)
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