2018-01-15 00:10:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Gitlab::Auth::BlockedUserTracker do
|
2018-07-20 10:00:28 -04:00
|
|
|
describe '#log_blocked_user_activity!' do
|
2018-08-01 09:56:44 -04:00
|
|
|
context 'when user is not blocked' do
|
2018-08-03 06:58:00 -04:00
|
|
|
it 'does not log blocked user activity' do
|
2018-08-01 09:56:44 -04:00
|
|
|
expect_any_instance_of(SystemHooksService)
|
|
|
|
.not_to receive(:execute_hooks_for)
|
|
|
|
expect(Gitlab::AppLogger).not_to receive(:info)
|
2018-07-27 07:54:31 -04:00
|
|
|
|
2018-08-01 09:56:44 -04:00
|
|
|
user = create(:user)
|
2018-01-15 00:10:48 -05:00
|
|
|
|
2018-08-01 11:08:59 -04:00
|
|
|
described_class.new(user, spy('auth')).log_activity!
|
2018-01-15 00:10:48 -05:00
|
|
|
end
|
2018-08-01 09:56:44 -04:00
|
|
|
end
|
2018-01-15 00:10:48 -05:00
|
|
|
|
2018-08-01 09:56:44 -04:00
|
|
|
context 'when user is not blocked' do
|
|
|
|
it 'logs blocked user activity' do
|
|
|
|
user = create(:user, :blocked)
|
2018-05-13 01:02:26 -04:00
|
|
|
|
2018-08-01 09:56:44 -04:00
|
|
|
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-01-15 00:10:48 -05:00
|
|
|
|
2018-08-01 11:08:59 -04:00
|
|
|
described_class.new(user, spy('auth')).log_activity!
|
2018-01-15 00:10:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|