diff options
author | Claire McQuin <claire@getchef.com> | 2014-07-09 11:29:12 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-07-09 11:29:12 -0700 |
commit | a3cfdf6b8d7d1a037d000f140adec59d2646da4d (patch) | |
tree | 9ce3e3357b7bf31cec28c3983454383a60d853c2 /spec/unit/http | |
parent | e51545d4af1d1d152bbf651a9898a96dab46c51d (diff) | |
download | chef-a3cfdf6b8d7d1a037d000f140adec59d2646da4d.tar.gz |
Add url scheme to proxy, if not present.
Diffstat (limited to 'spec/unit/http')
-rw-r--r-- | spec/unit/http/basic_client_spec.rb | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/unit/http/basic_client_spec.rb b/spec/unit/http/basic_client_spec.rb index 4a81288131..cb1f2fd979 100644 --- a/spec/unit/http/basic_client_spec.rb +++ b/spec/unit/http/basic_client_spec.rb @@ -38,5 +38,39 @@ describe "HTTP Connection" do subject.build_http_client.open_timeout.should_not be_nil end end -end + describe "#proxy_uri" do + shared_examples_for "a proxy uri" do + let(:proxy_host) { "proxy.mycorp.com" } + let(:proxy_port) { 8080 } + let(:proxy) { "#{proxy_prefix}#{proxy_host}:#{proxy_port}" } + + before do + Chef::Config["#{uri.scheme}_proxy"] = proxy + Chef::Config[:no_proxy] = nil + end + + it "should contain the host" do + proxy_uri = subject.proxy_uri + proxy_uri.host.should == proxy_host + end + + it "should contain the port" do + proxy_uri = subject.proxy_uri + proxy_uri.port.should == proxy_port + end + end + + context "when the config setting is normalized (does not contain the scheme)" do + include_examples "a proxy uri" do + let(:proxy_prefix) { "" } + end + end + + context "when the config setting is not normalized (contains the scheme)" do + include_examples "a proxy uri" do + let(:proxy_prefix) { "#{uri.scheme}://" } + end + end + end +end |