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
08f8c37b
Commit
08f8c37b
authored
Apr 14, 2022
by
Dustin Eckhardt
Committed by
Pavel Shutsin
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply project export download rate limit fix to api
See
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/82925
parent
3ba77373
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
1 deletion
+24
-1
lib/api/project_export.rb
lib/api/project_export.rb
+1
-1
spec/requests/api/project_export_spec.rb
spec/requests/api/project_export_spec.rb
+23
-0
No files found.
lib/api/project_export.rb
View file @
08f8c37b
...
...
@@ -25,7 +25,7 @@ module API
detail
'This feature was introduced in GitLab 10.6.'
end
get
':id/export/download'
do
check_rate_limit!
:project_download_export
,
scope:
[
current_user
,
user_project
]
check_rate_limit!
:project_download_export
,
scope:
[
current_user
,
user_project
.
namespace
]
if
user_project
.
export_file_exists?
if
user_project
.
export_archive_exists?
...
...
spec/requests/api/project_export_spec.rb
View file @
08f8c37b
...
...
@@ -260,6 +260,29 @@ RSpec.describe API::ProjectExport, :clean_gitlab_redis_cache do
expect
(
json_response
[
'message'
][
'error'
]).
to
eq
(
'This endpoint has been requested too many times. Try again later.'
)
end
end
context
'applies correct scope when throttling'
do
before
do
stub_application_setting
(
project_download_export_limit:
1
)
end
it
'throttles downloads within same namespaces'
do
# simulate prior request to the same namespace, which increments the rate limit counter for that scope
Gitlab
::
ApplicationRateLimiter
.
throttled?
(
:project_download_export
,
scope:
[
user
,
project_finished
.
namespace
])
get
api
(
download_path_finished
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:too_many_requests
)
end
it
'allows downloads from different namespaces'
do
# simulate prior request to a different namespace, which increments the rate limit counter for that scope
Gitlab
::
ApplicationRateLimiter
.
throttled?
(
:project_download_export
,
scope:
[
user
,
create
(
:project
,
:with_export
).
namespace
])
get
api
(
download_path_finished
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
end
end
context
'when user is a maintainer'
do
...
...
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