Commit e8b67da0 authored by Michael Kozono's avatar Michael Kozono

Merge branch...

Merge branch '335232-does-not-create-audit-event-for-failed-long-on-read-only-database' into 'master'

Do not create audit event for failed logins on read-only DB

See merge request gitlab-org/gitlab!65504
parents 0394b804 d073e732
......@@ -133,7 +133,7 @@ module EE
# @return [AuditEvent, nil] if record is persisted or nil if audit events
# features are not enabled
def unauth_security_event
return unless audit_events_enabled?
return unless audit_events_enabled? && ::Gitlab::Database.read_write?
add_security_event_admin_details!
......
......@@ -333,6 +333,16 @@ RSpec.describe AuditEventService, :request_store do
expect(event.details).not_to have_key(:ip_address)
end
end
context 'on a read-only instance' do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
it 'does not create an event record in the database' do
expect { service.for_failed_login.unauth_security_event }.not_to change(AuditEvent, :count)
end
end
end
describe '#for_project_group_link' do
......
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