Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMayra Cabrera <mcabrera@gitlab.com>2019-08-13 21:13:37 +0300
committerStan Hu <stanhu@gmail.com>2019-08-13 21:13:37 +0300
commitb6c51f57dd5637aaa4a45b7408a1f8b30ce3e7e3 (patch)
tree3e946b5af691ad3f3804d3e5a5fdf5f524da0cb0 /spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
parentbd759eebcd3d824bc95b08d91dcaf705b05769bb (diff)
Return 429 on rate limiter on raw endpoint
It was originally returning 302 when the rate limit kicks in, because using the the correct status code makes it easier to track rate limiting events Related to https://gitlab.com/gitlab-org/gitlab-ce/issues/65974
Diffstat (limited to 'spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb')
-rw-r--r--spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb b/spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
new file mode 100644
index 00000000000..6d587053b4f
--- /dev/null
+++ b/spec/features/projects/raw/user_interacts_with_raw_endpoint_spec.rb
@@ -0,0 +1,39 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe 'Projects > Raw > User interacts with raw endpoint' do
+ include RepoHelpers
+
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :repository, :public) }
+ let(:file_path) { 'master/README.md' }
+
+ before do
+ stub_application_setting(raw_blob_request_limit: 3)
+ project.add_developer(user)
+ create_file_in_repo(project, 'master', 'master', 'README.md', 'readme content')
+
+ sign_in(user)
+ end
+
+ context 'when user access a raw file' do
+ it 'renders the page successfully' do
+ visit project_raw_url(project, file_path)
+
+ expect(source).to eq('') # Body is filled in by gitlab-workhorse
+ end
+ end
+
+ context 'when user goes over the rate requests limit' do
+ it 'returns too many requests' do
+ 4.times do
+ visit project_raw_url(project, file_path)
+ end
+
+ expect(source).to have_content('You are being redirected')
+ click_link('redirected')
+ expect(page).to have_content('You cannot access the raw file. Please wait a minute.')
+ end
+ end
+end