summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/http_connection_adapter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/lib/gitlab/http_connection_adapter_spec.rb')
-rw-r--r--spec/lib/gitlab/http_connection_adapter_spec.rb36
1 files changed, 29 insertions, 7 deletions
diff --git a/spec/lib/gitlab/http_connection_adapter_spec.rb b/spec/lib/gitlab/http_connection_adapter_spec.rb
index 7c57d162e9b..e9e517f1fe6 100644
--- a/spec/lib/gitlab/http_connection_adapter_spec.rb
+++ b/spec/lib/gitlab/http_connection_adapter_spec.rb
@@ -15,11 +15,33 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
stub_all_dns('https://example.org', ip_address: '93.184.216.34')
end
+ context 'with use_read_total_timeout option' do
+ let(:options) { { use_read_total_timeout: true } }
+
+ it 'sets up the connection using the Gitlab::NetHttpAdapter' do
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
+ expect(connection.address).to eq('93.184.216.34')
+ expect(connection.hostname_override).to eq('example.org')
+ expect(connection.addr_port).to eq('example.org')
+ expect(connection.port).to eq(443)
+ end
+ end
+
+ context 'with header_read_timeout_buffered_io feature disabled' do
+ before do
+ stub_feature_flags(header_read_timeout_buffered_io: false)
+ end
+
+ it 'uses the regular Net::HTTP class' do
+ expect(connection).to be_a(Net::HTTP)
+ end
+ end
+
context 'when local requests are allowed' do
let(:options) { { allow_local_requests: true } }
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('93.184.216.34')
expect(connection.hostname_override).to eq('example.org')
expect(connection.addr_port).to eq('example.org')
@@ -31,7 +53,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
let(:options) { { allow_local_requests: false } }
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('93.184.216.34')
expect(connection.hostname_override).to eq('example.org')
expect(connection.addr_port).to eq('example.org')
@@ -52,7 +74,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
let(:options) { { allow_local_requests: true } }
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('172.16.0.0')
expect(connection.hostname_override).to be(nil)
expect(connection.addr_port).to eq('172.16.0.0')
@@ -75,7 +97,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
let(:options) { { allow_local_requests: true } }
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('127.0.0.1')
expect(connection.hostname_override).to be(nil)
expect(connection.addr_port).to eq('127.0.0.1')
@@ -88,7 +110,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
let(:uri) { URI('https://example.org:8080') }
it 'sets up the addr_port accordingly' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('93.184.216.34')
expect(connection.hostname_override).to eq('example.org')
expect(connection.addr_port).to eq('example.org:8080')
@@ -103,7 +125,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
end
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('example.org')
expect(connection.hostname_override).to eq(nil)
expect(connection.addr_port).to eq('example.org')
@@ -117,7 +139,7 @@ RSpec.describe Gitlab::HTTPConnectionAdapter do
end
it 'sets up the connection' do
- expect(connection).to be_a(Net::HTTP)
+ expect(connection).to be_a(Gitlab::NetHttpAdapter)
expect(connection.address).to eq('example.org')
expect(connection.hostname_override).to eq(nil)
expect(connection.addr_port).to eq('example.org')