-
-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow proxy configuration via HTTP_PROXY env var (#2161)
* Allow proxy config via environment * Unit tests for env[http_proxy] support * Update sentry-ruby/spec/sentry/transport/http_transport_spec.rb Co-authored-by: Stan Lo <[email protected]> * Add transport/configuration comments * Fixed Ruby version checks for proxy conf --------- Co-authored-by: Stan Lo <[email protected]>
- Loading branch information
1 parent
19251ea
commit c4e4797
Showing
4 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,7 +63,7 @@ | |
expect(subject.send(:conn).port).to eq(80) | ||
end | ||
end | ||
context "with http DSN" do | ||
context "with https DSN" do | ||
let(:dsn) { "https://12345:[email protected]/sentry/42" } | ||
|
||
it "sets port to 443" do | ||
|
@@ -129,13 +129,33 @@ | |
subject.send_data(data) | ||
end | ||
|
||
it "accepts a proxy from ENV[HTTP_PROXY]" do | ||
begin | ||
ENV["http_proxy"] = "https://stan:[email protected]:8080" | ||
|
||
stub_request(fake_response) do |_, http_obj| | ||
expect(http_obj.proxy_address).to eq("example.com") | ||
expect(http_obj.proxy_port).to eq(8080) | ||
|
||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.5") | ||
expect(http_obj.proxy_user).to eq("stan") | ||
expect(http_obj.proxy_pass).to eq("foobar") | ||
end | ||
end | ||
|
||
subject.send_data(data) | ||
ensure | ||
ENV["http_proxy"] = nil | ||
end | ||
end | ||
|
||
it "accepts custom timeout" do | ||
configuration.transport.timeout = 10 | ||
|
||
stub_request(fake_response) do |_, http_obj| | ||
expect(http_obj.read_timeout).to eq(10) | ||
|
||
if RUBY_VERSION >= "2.6" | ||
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6") | ||
expect(http_obj.write_timeout).to eq(10) | ||
end | ||
end | ||
|