diff options
-rw-r--r-- | lib/chef/http/socketless_chef_zero_client.rb | 2 | ||||
-rw-r--r-- | spec/unit/http_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/rest_spec.rb | 9 |
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")) |