Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1219 Net::HTTP still uses env proxy #1221

Merged
merged 3 commits into from Dec 23, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 20 additions & 17 deletions spec/support/shared_examples/request_method.rb
@@ -1,5 +1,18 @@
# frozen_string_literal: true

shared_examples 'proxy examples' do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really, I like this shared one.

it 'handles requests with proxy' do
res = conn.public_send(http_method, '/')
expect(res.status).to eq(200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A newline, yeah?

end

it 'handles proxy failures' do
request_stub.to_return(status: 407)

expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
end
end

shared_examples 'a request method' do |http_method|
let(:query_or_body) { method_with_body?(http_method) ? :body : :query }
let(:response) { conn.public_send(http_method, '/') }
Expand Down Expand Up @@ -223,16 +236,7 @@
conn_options[:proxy] = 'http://google.co.uk'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this value is a bit not-self-documenting? "Does Google act as a proxy? How?" the reader (me) might think.

end

it 'handles requests with proxy' do
res = conn.public_send(http_method, '/')
expect(res.status).to eq(200)
end

it 'handles proxy failures' do
request_stub.to_return(status: 407)

expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
end
include_examples 'proxy examples'
end

context 'when http_proxy env variable is set' do
Expand All @@ -244,15 +248,14 @@
end
end

it 'handles requests with proxy' do
res = conn.public_send(http_method, '/')
expect(res.status).to eq(200)
end
include_examples 'proxy examples'

it 'handles proxy failures' do
request_stub.to_return(status: 407)
context 'when the env proxy is ignored' do
around do |example|
with_env_proxy_disabled(&example)
end

expect { conn.public_send(http_method, '/') }.to raise_error(Faraday::ProxyAuthError)
include_examples 'proxy examples'
end
end
end