Skip to content

Commit

Permalink
Merge pull request #18073 from jrafanie/handle_blank_http_proxy_host
Browse files Browse the repository at this point in the history
Handle a blank value for the http_proxy host

(cherry picked from commit a17d07e)

https://bugzilla.redhat.com/show_bug.cgi?id=1639353
  • Loading branch information
bdunne authored and simaishi committed Nov 5, 2018
1 parent 08edb99 commit 44f505d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/vmdb/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def self.http_proxy_uri(proxy_config = :default)
# TODO: (julian) This looks really messy. Need to make it look nicer.

proxy = (::Settings.http_proxy[proxy_config] || ::Settings.http_proxy).to_h
return nil unless proxy[:host]
return nil if proxy[:host].blank?

user = proxy.delete(:user)
user &&= CGI.escape(user)
Expand Down
6 changes: 6 additions & 0 deletions spec/lib/vmdb/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@
expect(described_class.http_proxy_uri).to be_nil
end

it "with a blank host" do
# We couldn't save nil http_proxy host, so some host values will be ''
stub_settings_merge(:http_proxy => {:default => {:host => ''}})
expect(described_class.http_proxy_uri).to be_nil
end

it "with host" do
stub_settings(:http_proxy => {:default => {:host => "1.2.3.4", :port => nil, :user => nil, :password => nil}})
expect(described_class.http_proxy_uri).to eq(URI::Generic.build(:scheme => "http", :host => "1.2.3.4"))
Expand Down

0 comments on commit 44f505d

Please sign in to comment.