summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-07-09 11:29:12 -0700
committerClaire McQuin <claire@getchef.com>2014-07-09 11:29:12 -0700
commita3cfdf6b8d7d1a037d000f140adec59d2646da4d (patch)
tree9ce3e3357b7bf31cec28c3983454383a60d853c2 /spec
parente51545d4af1d1d152bbf651a9898a96dab46c51d (diff)
downloadchef-a3cfdf6b8d7d1a037d000f140adec59d2646da4d.tar.gz
Add url scheme to proxy, if not present.
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/http/basic_client_spec.rb36
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