diff options
author | tylercloke <tylercloke@gmail.com> | 2015-05-27 14:32:24 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-06-05 10:38:48 -0700 |
commit | 9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee (patch) | |
tree | 226227e7e32f421a0dde0f1ad2046059eff449c3 /spec/unit/knife_spec.rb | |
parent | 20f7e1c78c55d2a16d5033bc2bbe5904d225adb0 (diff) | |
download | chef-9b9d376f2e86cd2738c2c2928f77bf48f1dd20ee.tar.gz |
Added versioned Chef Object API support code and repaired Chef::User.create.
Also added Chef::User.create V1 API support. Chef::User.create will attempt to use V1 of the server API, and if it fails, it will fall back to V0.
Diffstat (limited to 'spec/unit/knife_spec.rb')
-rw-r--r-- | spec/unit/knife_spec.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 3e8a43eaf5..022256f370 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -140,7 +140,7 @@ describe Chef::Knife do 'X-Chef-Version' => Chef::VERSION, "Host"=>"api.opscode.piab", "X-REMOTE-REQUEST-ID"=>request_id, - 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::SERVER_API_VERSION}} + 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}} let(:request_id) {"1234"} @@ -399,11 +399,17 @@ describe Chef::Knife do it "formats 406s (non-supported API version error) nicely" do response = Net::HTTPNotAcceptable.new("1.1", "406", "Not Acceptable") response.instance_variable_set(:@read, true) # I hate you, net/http. - allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone", :min_version => "0", :max_version => "1")) + + # set the header + response["x-ops-server-api-version"] = Chef::JSONCompat.to_json(:min_version => "0", :max_version => "1", :request_version => "10000000") + + allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(:error => "sad trombone")) allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("406 Not Acceptable", response)) + knife.run_with_pretty_exceptions - expect(stderr.string).to include('The version of Chef that Knife is using is not supported by the Chef server you sent this request to') - expect(stderr.string).to include("This version of Chef requires a server API version of #{Chef::HTTP::Authenticator::SERVER_API_VERSION}") + expect(stderr.string).to include('The request that Knife sent was using API version 10000000') + expect(stderr.string).to include('The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1') + expect(stderr.string).to include('Please either update your Chef client or server to be a compatible set') end it "formats 500s nicely" do |