diff options
Diffstat (limited to 'spec/requests/api/group_export_spec.rb')
-rw-r--r-- | spec/requests/api/group_export_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/requests/api/group_export_spec.rb b/spec/requests/api/group_export_spec.rb index 02ae9d71702..9dd7797c768 100644 --- a/spec/requests/api/group_export_spec.rb +++ b/spec/requests/api/group_export_spec.rb @@ -82,6 +82,22 @@ describe API::GroupExport do expect(response).to have_gitlab_http_status(:not_found) end end + + context 'when the requests have exceeded the rate limit' do + before do + allow(Gitlab::ApplicationRateLimiter) + .to receive(:increment) + .and_return(Gitlab::ApplicationRateLimiter.rate_limits[:group_download_export][:threshold] + 1) + end + + it 'throttles the endpoint' do + get api(download_path, user) + + expect(json_response["message"]) + .to include('error' => 'This endpoint has been requested too many times. Try again later.') + expect(response).to have_gitlab_http_status :too_many_requests + end + end end describe 'POST /groups/:group_id/export' do @@ -139,5 +155,23 @@ describe API::GroupExport do expect(response).to have_gitlab_http_status(:not_found) end end + + context 'when the requests have exceeded the rate limit' do + before do + group.add_owner(user) + + allow(Gitlab::ApplicationRateLimiter) + .to receive(:increment) + .and_return(Gitlab::ApplicationRateLimiter.rate_limits[:group_export][:threshold] + 1) + end + + it 'throttles the endpoint' do + post api(path, user) + + expect(json_response["message"]) + .to include('error' => 'This endpoint has been requested too many times. Try again later.') + expect(response).to have_gitlab_http_status :too_many_requests + end + end end end |