summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-03-31 12:45:13 -0700
committerdanielsdeleo <dan@getchef.com>2015-04-01 13:35:01 -0700
commitf066fef19be99ba1b857ecaaabc4c70c9201f1d4 (patch)
tree3b3ef4f4ba872071949814eae60c4267e91b3a65
parentaab0ccb5d41913e050707bd6b40e5b820649c566 (diff)
downloadchef-f066fef19be99ba1b857ecaaabc4c70c9201f1d4.tar.gz
Test base HTTP client behaviors for chefzero URL case
-rw-r--r--lib/chef/http/socketless_chef_zero_client.rb2
-rw-r--r--spec/unit/http_spec.rb14
-rw-r--r--spec/unit/rest_spec.rb9
3 files changed, 25 insertions, 0 deletions
diff --git a/lib/chef/http/socketless_chef_zero_client.rb b/lib/chef/http/socketless_chef_zero_client.rb
index a64bfc8d4d..8f5543a16f 100644
--- a/lib/chef/http/socketless_chef_zero_client.rb
+++ b/lib/chef/http/socketless_chef_zero_client.rb
@@ -75,6 +75,8 @@ class Chef
end
+ attr_reader :url
+
# copied verbatim from webrick (2-clause BSD License)
#
# HTTP status codes and descriptions
diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb
index ddfc56583d..4d851df951 100644
--- a/spec/unit/http_spec.rb
+++ b/spec/unit/http_spec.rb
@@ -20,6 +20,7 @@ require 'spec_helper'
require 'chef/http'
require 'chef/http/basic_client'
+require 'chef/http/socketless_chef_zero_client'
class Chef::HTTP
public :create_url
@@ -27,6 +28,19 @@ end
describe Chef::HTTP do
+ context "when given a chefzero:// URL" do
+
+ let(:uri) { URI("chefzero://localhost:1") }
+
+ subject(:http) { Chef::HTTP.new(uri) }
+
+ it "uses the SocketlessChefZeroClient to handle requests" do
+ expect(http.http_client).to be_a_kind_of(Chef::HTTP::SocketlessChefZeroClient)
+ expect(http.http_client.url).to eq(uri)
+ end
+
+ end
+
describe "create_url" do
it 'should return a correctly formatted url 1/3 CHEF-5261' do
diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb
index 1aa7ac84ee..85c9e3df8f 100644
--- a/spec/unit/rest_spec.rb
+++ b/spec/unit/rest_spec.rb
@@ -92,6 +92,15 @@ describe Chef::REST do
Chef::REST.new(base_url, nil, nil, options)
end
+ context 'when created with a chef zero URL' do
+
+ let(:url) { "chefzero://localhost:1" }
+
+ it "does not load the signing key" do
+ expect { Chef::REST.new(url) }.to_not raise_error
+ end
+ end
+
describe "calling an HTTP verb on a path or absolute URL" do
it "adds a relative URL to the base url it was initialized with" do
expect(rest.create_url("foo/bar/baz")).to eq(URI.parse(base_url + "/foo/bar/baz"))