Port of 46361-does-not-log-failed-sign-in-attempts-when-the-database-is-in-read-only-mode to EE

parent 70e8f831
......@@ -5,7 +5,6 @@ module EE
# and be prepended in the `User` model
module User
extend ActiveSupport::Concern
extend ::Gitlab::Utils::Override
include AuditorUserHelper
included do
......@@ -92,10 +91,5 @@ module EE
def email_opted_in_source
email_opted_in_source_id == EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM ? 'GitLab.com' : ''
end
override :increment_failed_attempts!
def increment_failed_attempts!
super if ::Gitlab::Database.read_write?
end
end
end
......@@ -137,18 +137,4 @@ describe EE::User do
end
end
end
describe '#increment_failed_attempts!' do
subject(:user) { create(:user, failed_attempts: 0) }
it 'logs failed sign-in attempts' do
expect { user.increment_failed_attempts! }.to change(user, :failed_attempts).from(0).to(1)
end
it 'does not log failed sign-in attempts when in a GitLab read-only instance' do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect { user.increment_failed_attempts! }.not_to change(user, :failed_attempts)
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