summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/notes_controller_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-02-19 12:11:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-02-19 12:11:06 +0000
commit1fdc1d34e8e3cab28cd010a2b352974da9847e8e (patch)
treea8158b1ef1a1f09ccb7d4789a3d7e519d8825b37 /spec/controllers/projects/notes_controller_spec.rb
parentc44a81b8b9f4c27bec1f6df6ea25f135c390b730 (diff)
downloadgitlab-ce-1fdc1d34e8e3cab28cd010a2b352974da9847e8e.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/controllers/projects/notes_controller_spec.rb')
-rw-r--r--spec/controllers/projects/notes_controller_spec.rb46
1 files changed, 3 insertions, 43 deletions
diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb
index c0368ab8f3c..add249e2c74 100644
--- a/spec/controllers/projects/notes_controller_spec.rb
+++ b/spec/controllers/projects/notes_controller_spec.rb
@@ -762,49 +762,9 @@ RSpec.describe Projects::NotesController do
end
end
- context 'when the endpoint receives requests above the limit' do
- before do
- stub_application_setting(notes_create_limit: 3)
- end
-
- it 'prevents from creating more notes', :request_store do
- 3.times { create! }
-
- expect { create! }
- .to change { Gitlab::GitalyClient.get_request_count }.by(0)
-
- create!
- 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
-
- it 'logs the event in auth.log' do
- attributes = {
- message: 'Application_Rate_Limiter_Request',
- env: :notes_create_request_limit,
- remote_ip: '0.0.0.0',
- request_method: 'POST',
- path: "/#{project.full_path}/notes",
- user_id: user.id,
- username: user.username
- }
-
- expect(Gitlab::AuthLogger).to receive(:error).with(attributes).once
-
- project.add_developer(user)
- sign_in(user)
-
- 4.times { create! }
- end
-
- it 'allows user in allow-list to create notes, even if the case is different' do
- user.update_attribute(:username, user.username.titleize)
- stub_application_setting(notes_create_limit_allowlist: ["#{user.username.downcase}"])
- 3.times { create! }
-
- create!
- expect(response).to have_gitlab_http_status(:found)
- end
+ it_behaves_like 'request exceeding rate limit', :clean_gitlab_redis_cache do
+ let(:params) { request_params.except(:format) }
+ let(:request_full_path) { project_notes_path(project) }
end
end