2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::Auth::BlockedUserTracker do
|
2018-11-18 11:00:15 +05:30
|
|
|
describe '#log_blocked_user_activity!' do
|
|
|
|
context 'when user is not blocked' do
|
|
|
|
it 'does not log blocked user activity' do
|
|
|
|
expect_any_instance_of(SystemHooksService)
|
|
|
|
.not_to receive(:execute_hooks_for)
|
|
|
|
expect(Gitlab::AppLogger).not_to receive(:info)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
user = create(:user)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
described_class.new(user, spy('auth')).log_activity!
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'when user is not blocked' do
|
|
|
|
it 'logs blocked user activity' do
|
|
|
|
user = create(:user, :blocked)
|
2018-10-15 14:42:47 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
expect_any_instance_of(SystemHooksService)
|
|
|
|
.to receive(:execute_hooks_for)
|
|
|
|
.with(user, :failed_login)
|
|
|
|
expect(Gitlab::AppLogger).to receive(:info)
|
|
|
|
.with(/Failed login for blocked user/)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
described_class.new(user, spy('auth')).log_activity!
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|