Commit de5170d2 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'sh-geo-fix-middleware' into 'master'

Fix Geo middleware to work properly with multiple requests

See merge request !2239
parents c44be0d3 53986229
---
title: Fix Geo middleware to work properly with multiple requests
merge_request:
author:
......@@ -58,7 +58,7 @@ module Gitlab
end
def request
@request ||= Rack::Request.new(@env)
@env['rack.request'] ||= Rack::Request.new(@env)
end
def last_visited_url
......@@ -78,11 +78,11 @@ module Gitlab
end
def sidekiq_route
@request.path.start_with?('/admin/sidekiq')
request.path.start_with?('/admin/sidekiq')
end
def grack_route
@request.path.end_with?('.git/git-upload-pack')
request.path.end_with?('.git/git-upload-pack')
end
end
end
......
......@@ -35,7 +35,7 @@ describe Gitlab::Middleware::ReadonlyGeo, lib: true do
end
subject { described_class.new(fake_app) }
let(:request) { @request ||= Rack::MockRequest.new(rack_stack) }
let(:request) { Rack::MockRequest.new(rack_stack) }
context 'normal requests to a secondary Gitlab Geo' do
let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
......@@ -65,6 +65,16 @@ describe Gitlab::Middleware::ReadonlyGeo, lib: true do
expect(subject).to disallow_request
end
it 'expects a POST Geo request to be allowed after a disallowed request' do
response = request.post('/test_request')
expect(response).to be_a_redirect
response = request.post("/api/#{API::API.version}/geo/refresh_wikis")
expect(response).not_to be_a_redirect
end
it 'expects DELETE requests to be disallowed' do
response = request.delete('/test_request')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment