summaryrefslogtreecommitdiff
path: root/spec/controllers/projects
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 16:52:22 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-01 16:52:22 +0000
commit6528a71ac448f759b5615a7679abd3c0ab1afcb5 (patch)
tree273f4b187a53afd9a96c5320f14858d23da313f1 /spec/controllers/projects
parentcfd0aae22e1ecf9120abf2d828d037bfcf53d57c (diff)
downloadgitlab-ce-6528a71ac448f759b5615a7679abd3c0ab1afcb5.tar.gz
Add latest changes from gitlab-org/security/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r--spec/controllers/projects/hooks_controller_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/controllers/projects/hooks_controller_spec.rb b/spec/controllers/projects/hooks_controller_spec.rb
index 440e6b2a74c..68e91fa9c1f 100644
--- a/spec/controllers/projects/hooks_controller_spec.rb
+++ b/spec/controllers/projects/hooks_controller_spec.rb
@@ -46,4 +46,26 @@ RSpec.describe Projects::HooksController do
expect(ProjectHook.first).to have_attributes(hook_params)
end
end
+
+ describe '#test' do
+ let(:hook) { create(:project_hook, project: project) }
+
+ context 'when the endpoint receives requests above the limit' do
+ before do
+ allow(Gitlab::ApplicationRateLimiter).to receive(:rate_limits)
+ .and_return(project_testing_hook: { threshold: 1, interval: 1.minute })
+ end
+
+ it 'prevents making test requests' do
+ expect_next_instance_of(TestHooks::ProjectService) do |service|
+ expect(service).to receive(:execute).and_return(http_status: 200)
+ end
+
+ 2.times { post :test, params: { namespace_id: project.namespace, project_id: project, id: hook } }
+
+ expect(response.body).to eq(_('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