Merge branch 'sh-switch-rack-request-to-actionpack' into 'master'

Switch use of Rack::Request to ActionDispatch::Request

See merge request gitlab-org/gitlab-ce!24199
This commit is contained in:
Robert Speicher 2019-01-09 02:01:39 +00:00
commit 0986039896
9 changed files with 11 additions and 9 deletions

View file

@ -512,7 +512,7 @@ module API
# `request`. We workaround this by defining methods that returns the right
# values.
def define_params_for_grape_middleware
self.define_singleton_method(:request) { Rack::Request.new(env) }
self.define_singleton_method(:request) { ActionDispatch::Request.new(env) }
self.define_singleton_method(:params) { request.params.symbolize_keys }
end

View file

@ -8,7 +8,7 @@ module Gitlab
end
def call(env)
request = Rack::Request.new(env)
request = ActionDispatch::Request.new(env)
route = Gitlab::EtagCaching::Router.match(request.path_info)
return @app.call(env) unless route

View file

@ -24,7 +24,7 @@ module Gitlab
def call(env)
return @app.call(env) unless env['PATH_INFO'] == HEALTH_PATH
request = Rack::Request.new(env)
request = ActionDispatch::Request.new(env)
return OK_RESPONSE if client_ip_whitelisted?(request)

View file

@ -60,7 +60,7 @@ module Gitlab
end
def request
@env['rack.request'] ||= Rack::Request.new(@env)
@env['actionpack.request'] ||= ActionDispatch::Request.new(@env)
end
def last_visited_url

View file

@ -13,7 +13,7 @@ module Gitlab
end
def call(env)
req = Rack::Request.new(env)
req = ActionDispatch::Request.new(env)
Gitlab::SafeRequestStore[:client_ip] = req.ip

View file

@ -9,7 +9,7 @@ describe Gitlab::Auth::UserAuthFinders do
'rack.input' => ''
}
end
let(:request) { Rack::Request.new(env) }
let(:request) { ActionDispatch::Request.new(env) }
def set_param(key, value)
request.update_param(key, value)

View file

@ -15,7 +15,7 @@ describe Gitlab::RequestContext do
let(:ip) { '192.168.1.11' }
before do
allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip)
allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return(ip)
described_class.new(app).call(env)
end

View file

@ -25,6 +25,8 @@ describe OmniAuth::Strategies::Jwt do
subject.options[:secret] = secret
subject.options[:algorithm] = algorithm
# We use Rack::Request instead of ActionDispatch::Request because
# Rack::Test::Methods enables testing of this module.
expect_next_instance_of(Rack::Request) do |rack_request|
expect(rack_request).to receive(:params).and_return('jwt' => payload)
end

View file

@ -387,7 +387,7 @@ describe 'Git HTTP requests' do
it "responds with status 401" do
expect(Rack::Attack::Allow2Ban).to receive(:filter).and_return(true)
allow_any_instance_of(Rack::Request).to receive(:ip).and_return('1.2.3.4')
allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return('1.2.3.4')
clone_get(path, env)
@ -548,7 +548,7 @@ describe 'Git HTTP requests' do
maxretry = options[:maxretry] - 1
ip = '1.2.3.4'
allow_any_instance_of(Rack::Request).to receive(:ip).and_return(ip)
allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return(ip)
Rack::Attack::Allow2Ban.reset(ip, options)
maxretry.times.each do