Skip to content

Commit

Permalink
Merge pull request ManageIQ#18073 from jrafanie/handle_blank_http_pro…
Browse files Browse the repository at this point in the history
…xy_host

Handle a blank value for the http_proxy host
  • Loading branch information
bdunne authored Oct 10, 2018
2 parents dbbced8 + 5f55f94 commit a17d07e
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 @@ -3,7 +3,7 @@ module Util
def self.http_proxy_uri(proxy_config = :default)
proxy = ::Settings.http_proxy[proxy_config].to_hash
proxy = ::Settings.http_proxy.to_hash unless proxy[:host]
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_merge(: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 a17d07e

Please sign in to comment.