Skip to content
Snippets Groups Projects
Commit c67777cf authored by Moaz Khalifa's avatar Moaz Khalifa
Browse files

Fix Gitlab::HTTP_V2 allowed_internal_uris https scheme

We need to use the correct URI builder class when configuring Gitlab::HTTP_V2's allowed_internal_uris. Now we only use URI::HTTP which doesn't take into consideration the https scheme

Changelog: fixed
parent 6fdbc26b
No related branches found
No related tags found
1 merge request!146919Fix Gitlab::HTTP_V2 allowed_internal_uris https scheme
......@@ -5,8 +5,7 @@
Gitlab::HTTP_V2.configure do |config|
config.allowed_internal_uris = [
URI::HTTP.build(
scheme: Gitlab.config.gitlab.protocol,
(Gitlab.config.gitlab.protocol == 'https' ? URI::HTTPS : URI::HTTP).build(
host: Gitlab.config.gitlab.host,
port: Gitlab.config.gitlab.port
),
......
......@@ -3,6 +3,10 @@
require 'spec_helper'
RSpec.describe Gitlab::HTTP_V2, feature_category: :shared do
def load_initializer
load Rails.root.join('config/initializers/7_gitlab_http.rb')
end
it 'handles log_exception_proc' do
expect(Gitlab::HTTP_V2::Client).to receive(:httparty_perform_request)
.and_raise(Net::ReadTimeout)
......@@ -44,4 +48,26 @@
end
end
end
context 'when configuring allowed_internal_uris' do
subject(:uris) { described_class.configuration.allowed_internal_uris }
it do
is_expected.to contain_exactly(
URI::HTTP.build(host: 'localhost', port: 80),
URI::Generic.build(scheme: 'ssh', host: 'localhost', port: 22)
)
end
context 'when the protocol is https' do
before do
stub_config_setting(protocol: 'https')
load_initializer
end
it 'uses the correct scheme' do
expect(uris.first.scheme).to eq('https')
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment