summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-21 16:10:47 +0000
committerDouwe Maan <douwe@gitlab.com>2017-11-21 16:10:47 +0000
commit6c3398165469de7890cd7881b175858f7c6be8e5 (patch)
tree7eabd63dac17903c35ad7db650c8eebc9f41e89f /spec
parent9961ac033f091269b983de6887dc845ebe35fb5a (diff)
parentaeb2f49fd4c65b9f5e3b2d7858a250a747a0f702 (diff)
downloadgitlab-ce-6c3398165469de7890cd7881b175858f7c6be8e5.tar.gz
Merge branch 'sh-optimize-read-only-check' into 'master'
Optimize read-only middleware so that it does not consume as much CPU Closes #40185 and gitlab-com/infrastructure#3240 See merge request gitlab-org/gitlab-ce!15504
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/middleware/read_only_spec.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/lib/gitlab/middleware/read_only_spec.rb b/spec/lib/gitlab/middleware/read_only_spec.rb
index b14735943a5..07ba11b93a3 100644
--- a/spec/lib/gitlab/middleware/read_only_spec.rb
+++ b/spec/lib/gitlab/middleware/read_only_spec.rb
@@ -84,14 +84,23 @@ describe Gitlab::Middleware::ReadOnly do
end
it 'expects POST of new file that looks like an LFS batch url to be disallowed' do
+ expect(Rails.application.routes).to receive(:recognize_path).and_call_original
response = request.post('/root/gitlab-ce/new/master/app/info/lfs/objects/batch')
expect(response).to be_a_redirect
expect(subject).to disallow_request
end
+ it 'returns last_vistited_url for disallowed request' do
+ response = request.post('/test_request')
+
+ expect(response.location).to eq 'http://localhost/'
+ end
+
context 'whitelisted requests' do
it 'expects a POST internal request to be allowed' do
+ expect(Rails.application.routes).not_to receive(:recognize_path)
+
response = request.post("/api/#{API::API.version}/internal")
expect(response).not_to be_a_redirect
@@ -99,6 +108,7 @@ describe Gitlab::Middleware::ReadOnly do
end
it 'expects a POST LFS request to batch URL to be allowed' do
+ expect(Rails.application.routes).to receive(:recognize_path).and_call_original
response = request.post('/root/rouge.git/info/lfs/objects/batch')
expect(response).not_to be_a_redirect
@@ -106,6 +116,7 @@ describe Gitlab::Middleware::ReadOnly do
end
it 'expects a POST request to git-upload-pack URL to be allowed' do
+ expect(Rails.application.routes).to receive(:recognize_path).and_call_original
response = request.post('/root/rouge.git/git-upload-pack')
expect(response).not_to be_a_redirect