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
00babc80
Commit
00babc80
authored
Jan 06, 2021
by
Quang-Minh Nguyen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move RackAttack test out of ee test folder
Issue
https://gitlab.com/gitlab-com/gl-infra/scalability/-/issues/731
parent
e6afbd99
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
183 additions
and
183 deletions
+183
-183
ee/spec/lib/gitlab/rack_attack_spec.rb
ee/spec/lib/gitlab/rack_attack_spec.rb
+0
-183
spec/lib/gitlab/rack_attack_spec.rb
spec/lib/gitlab/rack_attack_spec.rb
+183
-0
No files found.
ee/spec/lib/gitlab/rack_attack_spec.rb
View file @
00babc80
...
...
@@ -25,187 +25,4 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
.
with
(
'throttle_incident_management_notification_web'
,
Gitlab
::
Throttle
.
authenticated_web_options
)
end
end
describe
'.throttled_response_headers'
do
where
(
:match_data
,
:headers
)
do
[
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
29
,
30
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1830'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1830'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
59
,
59
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
0
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'3600'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'3600'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
23
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Wed, 06 Jan 2021 00:00:00 GMT'
,
# Next day
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3400
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'57'
,
# 56.66 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3700
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'62'
,
# 61.66 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
59
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'1'
,
# 0.9833 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
61
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'2'
,
# 1.016 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
15
.
seconds
,
limit:
10
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'40'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'15'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 10:30:15 GMT'
,
'Retry-After'
=>
'15'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
27
.
seconds
,
limit:
10
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'23'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'27'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 10:30:27 GMT'
,
'Retry-After'
=>
'27'
}
]
]
end
with_them
do
it
'generates accurate throttled headers'
do
expect
(
described_class
.
throttled_response_headers
(
match_data
)).
to
eql
(
headers
)
end
end
end
end
spec/lib/gitlab/rack_attack_spec.rb
View file @
00babc80
...
...
@@ -98,4 +98,187 @@ RSpec.describe Gitlab::RackAttack, :aggregate_failures do
end
end
end
describe
'.throttled_response_headers'
do
where
(
:match_data
,
:headers
)
do
[
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
29
,
30
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1830'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1830'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
59
,
59
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
0
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'3600'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'3600'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3600
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
23
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'60'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Wed, 06 Jan 2021 00:00:00 GMT'
,
# Next day
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3400
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'57'
,
# 56.66 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
3700
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'62'
,
# 61.66 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
59
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'1'
,
# 0.9833 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
1
.
hour
,
limit:
61
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'2'
,
# 1.016 requests per minute
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'1800'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 11:00:00 GMT'
,
'Retry-After'
=>
'1800'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
15
.
seconds
,
limit:
10
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'40'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'15'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 10:30:15 GMT'
,
'Retry-After'
=>
'15'
}
],
[
{
discriminator:
'127.0.0.1'
,
count:
3700
,
period:
27
.
seconds
,
limit:
10
,
epoch_time:
Time
.
utc
(
2021
,
1
,
5
,
10
,
30
,
0
).
to_i
},
{
'RateLimit-Limit'
=>
'23'
,
'RateLimit-Observed'
=>
'3700'
,
'RateLimit-Remaining'
=>
'0'
,
'RateLimit-Reset'
=>
'27'
,
'RateLimit-ResetTime'
=>
'Tue, 05 Jan 2021 10:30:27 GMT'
,
'Retry-After'
=>
'27'
}
]
]
end
with_them
do
it
'generates accurate throttled headers'
do
expect
(
described_class
.
throttled_response_headers
(
match_data
)).
to
eql
(
headers
)
end
end
end
end
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