From f066fef19be99ba1b857ecaaabc4c70c9201f1d4 Mon Sep 17 00:00:00 2001 From: danielsdeleo Date: Tue, 31 Mar 2015 12:45:13 -0700 Subject: Test base HTTP client behaviors for chefzero URL case --- spec/unit/http_spec.rb | 14 ++++++++++++++ spec/unit/rest_spec.rb | 9 +++++++++ 2 files changed, 23 insertions(+) (limited to 'spec') 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")) -- cgit v1.2.1