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
2f96c803
Commit
2f96c803
authored
Oct 05, 2020
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Ruby 2.7 kwargs deprecation warning in rack_attack_spec
parent
79d36849
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
ee/spec/requests/rack_attack_spec.rb
ee/spec/requests/rack_attack_spec.rb
+9
-9
spec/support/helpers/rack_attack_spec_helpers.rb
spec/support/helpers/rack_attack_spec_helpers.rb
+0
-4
No files found.
ee/spec/requests/rack_attack_spec.rb
View file @
2f96c803
...
@@ -23,7 +23,7 @@ RSpec.describe 'Rack Attack EE throttles' do
...
@@ -23,7 +23,7 @@ RSpec.describe 'Rack Attack EE throttles' do
}
}
end
end
let
(
:post_args
)
{
post_args_with_token_headers
(
path
,
oauth_token_headers
(
token
))
}
let
(
:post_args
)
{
{
headers:
oauth_token_headers
(
token
)
}
}
before
do
before
do
stub_application_setting
(
settings_to_set
)
stub_application_setting
(
settings_to_set
)
...
@@ -39,29 +39,29 @@ RSpec.describe 'Rack Attack EE throttles' do
...
@@ -39,29 +39,29 @@ RSpec.describe 'Rack Attack EE throttles' do
it
'rejects requests over the rate limit'
do
it
'rejects requests over the rate limit'
do
# At first, allow requests under the rate limit.
# At first, allow requests under the rate limit.
requests_per_period
.
times
do
requests_per_period
.
times
do
post
(
*
post_args
)
post
(
path
,
*
*
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
# the last straw
# the last straw
expect_rejection
{
post
(
*
post_args
)
}
expect_rejection
{
post
(
path
,
*
*
post_args
)
}
end
end
it
'allows requests after throttling and then waiting for the next period'
do
it
'allows requests after throttling and then waiting for the next period'
do
requests_per_period
.
times
do
requests_per_period
.
times
do
post
(
*
post_args
)
post
(
path
,
*
*
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
expect_rejection
{
post
(
*
post_args
)
}
expect_rejection
{
post
(
path
,
*
*
post_args
)
}
Timecop
.
travel
(
period
.
from_now
)
do
Timecop
.
travel
(
period
.
from_now
)
do
requests_per_period
.
times
do
requests_per_period
.
times
do
post
(
*
post_args
)
post
(
path
,
*
*
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
expect_rejection
{
post
(
*
post_args
)
}
expect_rejection
{
post
(
path
,
*
*
post_args
)
}
end
end
end
end
end
end
...
@@ -72,12 +72,12 @@ RSpec.describe 'Rack Attack EE throttles' do
...
@@ -72,12 +72,12 @@ RSpec.describe 'Rack Attack EE throttles' do
it
'allows requests over the rate limit'
do
it
'allows requests over the rate limit'
do
# At first, allow requests under the rate limit.
# At first, allow requests under the rate limit.
requests_per_period
.
times
do
requests_per_period
.
times
do
post
(
*
post_args
)
post
(
path
,
*
*
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
# requests still allowed
# requests still allowed
post
(
*
post_args
)
post
(
path
,
*
*
post_args
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
end
...
...
spec/support/helpers/rack_attack_spec_helpers.rb
View file @
2f96c803
# frozen_string_literal: true
# frozen_string_literal: true
module
RackAttackSpecHelpers
module
RackAttackSpecHelpers
def
post_args_with_token_headers
(
url
,
token_headers
)
[
url
,
params:
nil
,
headers:
token_headers
]
end
def
api_get_args_with_token_headers
(
partial_url
,
token_headers
)
def
api_get_args_with_token_headers
(
partial_url
,
token_headers
)
[
"/api/
#{
API
::
API
.
version
}#{
partial_url
}
"
,
params:
nil
,
headers:
token_headers
]
[
"/api/
#{
API
::
API
.
version
}#{
partial_url
}
"
,
params:
nil
,
headers:
token_headers
]
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