Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
9182f7d6
Commit
9182f7d6
authored
Jan 25, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove dependency injection
parent
1533894a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
lib/gitlab/metrics/subscribers/rack_attack.rb
lib/gitlab/metrics/subscribers/rack_attack.rb
+5
-5
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
+4
-5
No files found.
lib/gitlab/metrics/subscribers/rack_attack.rb
View file @
9182f7d6
...
...
@@ -34,10 +34,6 @@ module Gitlab
}
end
def
initialize
(
auth_logger:
Gitlab
::
AuthLogger
)
@auth_logger
=
auth_logger
end
def
redis
(
event
)
self
.
class
.
payload
[
:rack_attack_redis_count
]
+=
1
self
.
class
.
payload
[
:rack_attack_redis_duration_s
]
+=
event
.
duration
.
to_f
/
1000
...
...
@@ -81,7 +77,11 @@ module Gitlab
rack_attack_info
[
'meta.user'
]
=
user
.
username
unless
user
.
nil?
end
@auth_logger
.
error
(
rack_attack_info
)
logger
.
error
(
rack_attack_info
)
end
def
logger
Gitlab
::
AuthLogger
end
end
end
...
...
spec/lib/gitlab/metrics/subscribers/rack_attack_spec.rb
View file @
9182f7d6
...
...
@@ -3,8 +3,7 @@
require
'spec_helper'
RSpec
.
describe
Gitlab
::
Metrics
::
Subscribers
::
RackAttack
,
:request_store
do
let
(
:logger
)
{
double
(
:logger
)
}
let
(
:subscriber
)
{
described_class
.
new
(
auth_logger:
logger
)
}
let
(
:subscriber
)
{
described_class
.
new
}
describe
'.payload'
do
context
'when the request store is empty'
do
...
...
@@ -78,7 +77,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it
'logs request information'
do
expect
(
l
ogger
).
to
receive
(
:error
).
with
(
expect
(
Gitlab
::
AuthL
ogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
...
...
@@ -109,7 +108,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it
'logs request information and user id'
do
expect
(
l
ogger
).
to
receive
(
:error
).
with
(
expect
(
Gitlab
::
AuthL
ogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
...
...
@@ -141,7 +140,7 @@ RSpec.describe Gitlab::Metrics::Subscribers::RackAttack, :request_store do
end
it
'logs request information and user meta'
do
expect
(
l
ogger
).
to
receive
(
:error
).
with
(
expect
(
Gitlab
::
AuthL
ogger
).
to
receive
(
:error
).
with
(
message:
'Rack_Attack'
,
env:
match_type
,
remote_ip:
'1.2.3.4'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment