summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-12-07 11:15:23 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2019-01-03 10:53:48 -0800
commit10db9b3a50eae9c4c966f39f5beca8f5c17d441e (patch)
tree596bb3da0bcd1e2fe9a24e3a376fd6223cb6156f /spec
parent94ba9c022e57feb2949e22656d811a843b3410f1 (diff)
downloadchef-10db9b3a50eae9c4c966f39f5beca8f5c17d441e.tar.gz
change HTTPServerException to HTTPClientException for ruby 2.6
includes backcompat for 2.5 Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/http/simple_spec.rb20
-rw-r--r--spec/integration/knife/client_create_spec.rb2
-rw-r--r--spec/integration/knife/client_key_create_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_download_spec.rb2
-rw-r--r--spec/integration/knife/cookbook_show_spec.rb4
-rw-r--r--spec/integration/knife/data_bag_create_spec.rb2
-rw-r--r--spec/integration/knife/environment_create_spec.rb2
-rw-r--r--spec/integration/knife/node_create_spec.rb2
-rw-r--r--spec/integration/knife/role_create_spec.rb2
-rw-r--r--spec/support/shared/context/client.rb2
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb10
-rw-r--r--spec/support/shared/unit/api_versioning.rb4
-rw-r--r--spec/unit/api_client/registration_spec.rb2
-rw-r--r--spec/unit/api_client_spec.rb4
-rw-r--r--spec/unit/api_client_v1_spec.rb6
-rw-r--r--spec/unit/chef_fs/file_system/operation_failed_error_spec.rb2
-rw-r--r--spec/unit/client_spec.rb2
-rw-r--r--spec/unit/data_bag_item_spec.rb2
-rw-r--r--spec/unit/data_bag_spec.rb2
-rw-r--r--spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb8
-rw-r--r--spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb4
-rw-r--r--spec/unit/knife/bootstrap/client_builder_spec.rb2
-rw-r--r--spec/unit/knife/cookbook_delete_spec.rb6
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb4
-rw-r--r--spec/unit/knife/supermarket_share_spec.rb2
-rw-r--r--spec/unit/knife/supermarket_unshare_spec.rb6
-rw-r--r--spec/unit/knife_spec.rb14
-rw-r--r--spec/unit/mixin/api_version_request_handling_spec.rb4
-rw-r--r--spec/unit/node_spec.rb4
-rw-r--r--spec/unit/policy_builder/policyfile_spec.rb4
-rw-r--r--spec/unit/provider/remote_file/content_spec.rb4
-rw-r--r--spec/unit/resource_reporter_spec.rb14
-rw-r--r--spec/unit/user_v1_spec.rb4
33 files changed, 77 insertions, 77 deletions
diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb
index e835bb0c79..313fed064b 100644
--- a/spec/functional/http/simple_spec.rb
+++ b/spec/functional/http/simple_spec.rb
@@ -61,27 +61,27 @@ describe Chef::HTTP::Simple do
end
shared_examples_for "an endpoint that 403s" do
- it "fails with a Net::HTTPServerException for a streaming request" do
- expect { http_client.streaming_request(source) }.to raise_error(Net::HTTPServerException)
+ it "fails with a Net::HTTPClientException for a streaming request" do
+ expect { http_client.streaming_request(source) }.to raise_error(Net::HTTPClientException)
end
- it "fails with a Net::HTTPServerException for a GET request" do
- expect { http_client.get(source) }.to raise_error(Net::HTTPServerException)
+ it "fails with a Net::HTTPClientException for a GET request" do
+ expect { http_client.get(source) }.to raise_error(Net::HTTPClientException)
end
end
# see CHEF-5100
shared_examples_for "a 403 after a successful request when reusing the request object" do
- it "fails with a Net::HTTPServerException for a streaming request" do
+ it "fails with a Net::HTTPClientException for a streaming request" do
tempfile = http_client.streaming_request(source)
tempfile.close
expect(Digest::MD5.hexdigest(binread(tempfile.path))).to eq(Digest::MD5.hexdigest(expected_content))
- expect { http_client.streaming_request(source2) }.to raise_error(Net::HTTPServerException)
+ expect { http_client.streaming_request(source2) }.to raise_error(Net::HTTPClientException)
end
- it "fails with a Net::HTTPServerException for a GET request" do
+ it "fails with a Net::HTTPClientException for a GET request" do
expect(Digest::MD5.hexdigest(http_client.get(source))).to eq(Digest::MD5.hexdigest(expected_content))
- expect { http_client.get(source2) }.to raise_error(Net::HTTPServerException)
+ expect { http_client.get(source2) }.to raise_error(Net::HTTPClientException)
end
end
@@ -120,7 +120,7 @@ describe Chef::HTTP::Simple do
it "Logs the request and response and bodies for 400 response" do
expect do
http_client.get("http://localhost:9000/bad_request")
- end.to raise_error(Net::HTTPServerException)
+ end.to raise_error(Net::HTTPClientException)
expect(@debug_log).to match(/400/)
expect(@debug_log).to match(/HTTP Request Header Data/)
expect(@debug_log).to match(/HTTP Status and Header Data/)
@@ -133,7 +133,7 @@ describe Chef::HTTP::Simple do
it "Logs the request and response and bodies for 400 POST response" do
expect do
http_client.post("http://localhost:9000/bad_request", "hithere")
- end.to raise_error(Net::HTTPServerException)
+ end.to raise_error(Net::HTTPClientException)
expect(@debug_log).to match(/400/)
expect(@debug_log).to match(/HTTP Request Header Data/)
expect(@debug_log).to match(/HTTP Status and Header Data/)
diff --git a/spec/integration/knife/client_create_spec.rb b/spec/integration/knife/client_create_spec.rb
index d24755a48a..86609a63cd 100644
--- a/spec/integration/knife/client_create_spec.rb
+++ b/spec/integration/knife/client_create_spec.rb
@@ -44,7 +44,7 @@ EOM
it "refuses to add an existing client" do
pending "Knife client create must not blindly overwrite an existing client"
knife("client create -k bah").should_succeed stderr: out
- expect { knife("client create -k bah") }.to raise_error(Net::HTTPServerException)
+ expect { knife("client create -k bah") }.to raise_error(Net::HTTPClientException)
end
it "saves the private key to a file" do
diff --git a/spec/integration/knife/client_key_create_spec.rb b/spec/integration/knife/client_key_create_spec.rb
index b588afbe50..7ccec8bffd 100644
--- a/spec/integration/knife/client_key_create_spec.rb
+++ b/spec/integration/knife/client_key_create_spec.rb
@@ -43,7 +43,7 @@ describe "knife client key create", :workstation do
it "refuses to add an already existing key" do
knife("client key create -k new bah")
- expect { knife("client key create -k new bah") }.to raise_error(Net::HTTPServerException)
+ expect { knife("client key create -k new bah") }.to raise_error(Net::HTTPClientException)
end
it "saves the private key to a file" do
diff --git a/spec/integration/knife/cookbook_download_spec.rb b/spec/integration/knife/cookbook_download_spec.rb
index 57174a1548..2dbf9e5ae5 100644
--- a/spec/integration/knife/cookbook_download_spec.rb
+++ b/spec/integration/knife/cookbook_download_spec.rb
@@ -49,7 +49,7 @@ EOM
end
it "knife cookbook download with an unknown version raises an error" do
- expect { knife("cookbook download -d #{tmpdir} x 1.0.0") }.to raise_error(Net::HTTPServerException)
+ expect { knife("cookbook download -d #{tmpdir} x 1.0.0") }.to raise_error(Net::HTTPClientException)
end
end
diff --git a/spec/integration/knife/cookbook_show_spec.rb b/spec/integration/knife/cookbook_show_spec.rb
index fe7e6fa930..a8e87204e4 100644
--- a/spec/integration/knife/cookbook_show_spec.rb
+++ b/spec/integration/knife/cookbook_show_spec.rb
@@ -138,11 +138,11 @@ EOM
end
it "knife cookbook show with a non-existent version displays an error" do
- expect { knife("cookbook show x 1.0.1") }.to raise_error(Net::HTTPServerException)
+ expect { knife("cookbook show x 1.0.1") }.to raise_error(Net::HTTPClientException)
end
it "knife cookbook show with a non-existent cookbook displays an error" do
- expect { knife("cookbook show y") }.to raise_error(Net::HTTPServerException)
+ expect { knife("cookbook show y") }.to raise_error(Net::HTTPClientException)
end
end
end
diff --git a/spec/integration/knife/data_bag_create_spec.rb b/spec/integration/knife/data_bag_create_spec.rb
index dc61d55fd5..5ee7a2f00d 100644
--- a/spec/integration/knife/data_bag_create_spec.rb
+++ b/spec/integration/knife/data_bag_create_spec.rb
@@ -49,7 +49,7 @@ describe "knife data bag create", :workstation do
it "fails to add an existing item" do
knife("data bag create foo bar").should_succeed stdout: out, stderr: err
- expect { knife("data bag create foo bar") }.to raise_error(Net::HTTPServerException)
+ expect { knife("data bag create foo bar") }.to raise_error(Net::HTTPClientException)
end
end
end
diff --git a/spec/integration/knife/environment_create_spec.rb b/spec/integration/knife/environment_create_spec.rb
index 03fd4e63f7..2647a08f8b 100644
--- a/spec/integration/knife/environment_create_spec.rb
+++ b/spec/integration/knife/environment_create_spec.rb
@@ -33,7 +33,7 @@ describe "knife environment create", :workstation do
it "refuses to add an existing environment" do
pending "Knife environment create must not blindly overwrite an existing environment"
knife("environment create bah").should_succeed out
- expect { knife("environment create bah") }.to raise_error(Net::HTTPServerException)
+ expect { knife("environment create bah") }.to raise_error(Net::HTTPClientException)
end
end
diff --git a/spec/integration/knife/node_create_spec.rb b/spec/integration/knife/node_create_spec.rb
index 93a2f9ce6f..36778b3dfa 100644
--- a/spec/integration/knife/node_create_spec.rb
+++ b/spec/integration/knife/node_create_spec.rb
@@ -39,7 +39,7 @@ describe "knife node create", :workstation do
it "refuses to add an existing node" do
pending "Knife node create must not blindly overwrite an existing node"
knife("node create bah").should_succeed out
- expect { knife("node create bah") }.to raise_error(Net::HTTPServerException)
+ expect { knife("node create bah") }.to raise_error(Net::HTTPClientException)
end
end
diff --git a/spec/integration/knife/role_create_spec.rb b/spec/integration/knife/role_create_spec.rb
index 941eaf5cb6..54ade9de09 100644
--- a/spec/integration/knife/role_create_spec.rb
+++ b/spec/integration/knife/role_create_spec.rb
@@ -33,7 +33,7 @@ describe "knife role create", :workstation do
it "refuses to add an existing role" do
pending "Knife role create must not blindly overwrite an existing role"
knife("role create bah").should_succeed out
- expect { knife("role create bah") }.to raise_error(Net::HTTPServerException)
+ expect { knife("role create bah") }.to raise_error(Net::HTTPClientException)
end
end
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 0054058d0f..d6c49c896b 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -142,7 +142,7 @@ shared_context "a client run" do
def stub_for_required_recipe
response = Net::HTTPNotFound.new("1.1", "404", "Not Found")
- exception = Net::HTTPServerException.new('404 "Not Found"', response)
+ exception = Net::HTTPClientException.new('404 "Not Found"', response)
expect(http_node_load).to receive(:get).with("required_recipe").and_raise(exception)
end
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index 15c122e3dc..92ed9fcb99 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -71,7 +71,7 @@ shared_examples_for "an api error inspector" do
@response_body = "synchronize the clock on your host"
@response = Net::HTTPUnauthorized.new("1.1", "401", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
+ @exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
@inspector = described_class.new(@node_name, @exception, @config)
@inspector.add_explanation(@description)
end
@@ -87,7 +87,7 @@ shared_examples_for "an api error inspector" do
@response_body = "check your key and node name"
@response = Net::HTTPUnauthorized.new("1.1", "401", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
+ @exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
@inspector = described_class.new(@node_name, @exception, @config)
@inspector.add_explanation(@description)
end
@@ -103,7 +103,7 @@ shared_examples_for "an api error inspector" do
@response_body = "forbidden"
@response = Net::HTTPForbidden.new("1.1", "403", "(response) forbidden")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) forbidden", @response)
+ @exception = Net::HTTPClientException.new("(exception) forbidden", @response)
@inspector = described_class.new(@node_name, @exception, @config)
@inspector.add_explanation(@description)
end
@@ -119,7 +119,7 @@ shared_examples_for "an api error inspector" do
@response_body = "didn't like your data"
@response = Net::HTTPBadRequest.new("1.1", "400", "(response) bad request")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) bad request", @response)
+ @exception = Net::HTTPClientException.new("(exception) bad request", @response)
@inspector = described_class.new(@node_name, @exception, @config)
@inspector.add_explanation(@description)
end
@@ -135,7 +135,7 @@ shared_examples_for "an api error inspector" do
@response_body = "probably caused by a redirect to a get"
@response = Net::HTTPNotFound.new("1.1", "404", "(response) not found")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) not found", @response)
+ @exception = Net::HTTPClientException.new("(exception) not found", @response)
@inspector = described_class.new(@node_name, @exception, @config)
@inspector.add_explanation(@description)
end
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index 9c179efa82..55718971ef 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -20,7 +20,7 @@ require "chef/exceptions"
shared_examples_for "version handling" do
let(:response_406) { OpenStruct.new(code: "406") }
- let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
+ let(:exception_406) { Net::HTTPClientException.new("406 Not Acceptable", response_406) }
before do
allow(rest_v1).to receive(http_verb).and_raise(exception_406)
@@ -39,7 +39,7 @@ end # version handling
shared_examples_for "user and client reregister" do
let(:response_406) { OpenStruct.new(code: "406") }
- let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
+ let(:exception_406) { Net::HTTPClientException.new("406 Not Acceptable", response_406) }
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
let(:max_version) { "5" }
diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb
index 407c2c9f07..6fd1d4d0e1 100644
--- a/spec/unit/api_client/registration_spec.rb
+++ b/spec/unit/api_client/registration_spec.rb
@@ -61,7 +61,7 @@ describe Chef::ApiClient::Registration do
end
let(:response_409) { Net::HTTPConflict.new("1.1", "409", "Conflict") }
- let(:exception_409) { Net::HTTPServerException.new("409 conflict", response_409) }
+ let(:exception_409) { Net::HTTPClientException.new("409 conflict", response_409) }
let(:generated_private_key_pem) { IO.read(File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)) }
let(:generated_private_key) { OpenSSL::PKey::RSA.new(generated_private_key_pem) }
diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb
index e83906e712..e6b2eec820 100644
--- a/spec/unit/api_client_spec.rb
+++ b/spec/unit/api_client_spec.rb
@@ -280,13 +280,13 @@ describe Chef::ApiClient do
context "and the client does not exist on the server" do
before do
@a_404_response = Net::HTTPNotFound.new("404 not found and such", nil, nil)
- @a_404_exception = Net::HTTPServerException.new("404 not found exception", @a_404_response)
+ @a_404_exception = Net::HTTPClientException.new("404 not found exception", @a_404_response)
expect(@http_client).to receive(:get).with("clients/lost-my-key").and_raise(@a_404_exception)
end
it "raises a 404 error" do
- expect { Chef::ApiClient.reregister("lost-my-key") }.to raise_error(Net::HTTPServerException)
+ expect { Chef::ApiClient.reregister("lost-my-key") }.to raise_error(Net::HTTPClientException)
end
end
diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb
index 802384534b..6c4e7fe188 100644
--- a/spec/unit/api_client_v1_spec.rb
+++ b/spec/unit/api_client_v1_spec.rb
@@ -312,20 +312,20 @@ describe Chef::ApiClientV1 do
context "and the client does not exist on the server" do
before do
@a_404_response = Net::HTTPNotFound.new("404 not found and such", nil, nil)
- @a_404_exception = Net::HTTPServerException.new("404 not found exception", @a_404_response)
+ @a_404_exception = Net::HTTPClientException.new("404 not found exception", @a_404_response)
expect(@http_client).to receive(:get).with("clients/lost-my-key").and_raise(@a_404_exception)
end
it "raises a 404 error" do
- expect { Chef::ApiClientV1.reregister("lost-my-key") }.to raise_error(Net::HTTPServerException)
+ expect { Chef::ApiClientV1.reregister("lost-my-key") }.to raise_error(Net::HTTPClientException)
end
end
end
describe "Versioned API Interactions" do
let(:response_406) { OpenStruct.new(code: "406") }
- let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
+ let(:exception_406) { Net::HTTPClientException.new("406 Not Acceptable", response_406) }
let(:payload) do
{
name: "some_name",
diff --git a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
index acdbe35c45..661994337b 100644
--- a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
+++ b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb
@@ -29,7 +29,7 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do
response_body = '{"error":["Invalid key test in request body"]}'
allow(@response).to receive(:code).and_return("400")
allow(@response).to receive(:body).and_return(response_body)
- exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
+ exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
expect do
raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self, exception), error_message
end.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, "#{error_message} cause: #{response_body}")
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index acb5fb7997..9e20058846 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -441,7 +441,7 @@ EOM
context "when required_recipe returns 404" do
let(:http_response) { Net::HTTPNotFound.new("1.1", "404", "Not Found") }
- let(:http_exception) { Net::HTTPServerException.new('404 "Not Found"', http_response) }
+ let(:http_exception) { Net::HTTPClientException.new('404 "Not Found"', http_response) }
before(:each) do
expect(rest).to receive(:get).with("required_recipe").and_raise(http_exception)
diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb
index 3ebbf5c9a0..70fcd7041e 100644
--- a/spec/unit/data_bag_item_spec.rb
+++ b/spec/unit/data_bag_item_spec.rb
@@ -298,7 +298,7 @@ describe Chef::DataBagItem do
it "should create if the item is not found" do
exception = double("404 error", code: "404")
- expect(server).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception))
+ expect(server).to receive(:put).and_raise(Net::HTTPClientException.new("foo", exception))
expect(server).to receive(:post).with("data/books", data_bag_item)
data_bag_item.save
end
diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb
index f20148de72..388c35232f 100644
--- a/spec/unit/data_bag_spec.rb
+++ b/spec/unit/data_bag_spec.rb
@@ -89,7 +89,7 @@ describe Chef::DataBag do
it "should silently proceed when the data bag already exists" do
exception = double("409 error", code: "409")
- expect(@rest).to receive(:post).and_raise(Net::HTTPServerException.new("foo", exception))
+ expect(@rest).to receive(:post).and_raise(Net::HTTPClientException.new("foo", exception))
@data_bag.save
end
diff --git a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
index 07643385b4..35ae5378cf 100644
--- a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb
@@ -35,7 +35,7 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
@response_body = %q({"error": [{"message": "gtfo"}])
@response = Net::HTTPForbidden.new("1.1", "403", "(response) forbidden")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) forbidden", @response)
+ @exception = Net::HTTPClientException.new("(exception) forbidden", @response)
@inspector = Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector.new(@expanded_run_list, @exception)
@inspector.add_explanation(@description)
@@ -56,7 +56,7 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
@response_body = "{\"error\":[\"{\\\"non_existent_cookbooks\\\":[\\\"apache2\\\"],\\\"cookbooks_with_no_versions\\\":[\\\"users\\\"],\\\"message\\\":\\\"Run list contains invalid items: no such cookbook nope.\\\"}\"]}"
@response = Net::HTTPPreconditionFailed.new("1.1", "412", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) precondition failed", @response)
+ @exception = Net::HTTPClientException.new("(exception) precondition failed", @response)
@inspector = Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector.new(@expanded_run_list, @exception)
@inspector.add_explanation(@description)
@@ -84,7 +84,7 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
@response_body = "{\"error\":[{\"non_existent_cookbooks\":[],\"cookbooks_with_no_versions\":[],\"message\":\"unable to solve dependencies in alotted time.\"}]}"
@response = Net::HTTPPreconditionFailed.new("1.1", "412", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) precondition failed", @response)
+ @exception = Net::HTTPClientException.new("(exception) precondition failed", @response)
@inspector = Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector.new(@expanded_run_list, @exception)
@inspector.add_explanation(@description)
@@ -107,7 +107,7 @@ describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do
@response_body = "{\"error\":[{\"non_existent_cookbooks\":[\"apache2\"],\"cookbooks_with_no_versions\":[\"users\"],\"message\":\"Run list contains invalid items: no such cookbook nope.\"}]}"
@response = Net::HTTPPreconditionFailed.new("1.1", "412", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) precondition failed", @response)
+ @exception = Net::HTTPClientException.new("(exception) precondition failed", @response)
@inspector = Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector.new(@expanded_run_list, @exception)
@inspector.add_explanation(@description)
diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
index 70cf96f7c9..57f1f53f2c 100644
--- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
+++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb
@@ -55,7 +55,7 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@response_body = "forbidden"
@response = Net::HTTPForbidden.new("1.1", "403", "(response) forbidden")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) forbidden", @response)
+ @exception = Net::HTTPClientException.new("(exception) forbidden", @response)
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com")
@@ -73,7 +73,7 @@ describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do
@response_body = "check your key and node name"
@response = Net::HTTPUnauthorized.new("1.1", "401", "(response) unauthorized")
allow(@response).to receive(:body).and_return(@response_body)
- @exception = Net::HTTPServerException.new("(exception) unauthorized", @response)
+ @exception = Net::HTTPClientException.new("(exception) unauthorized", @response)
@inspector = Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector.new(@node, @exception)
allow(@inspector).to receive(:config).and_return(node_name: "unit-test.example.com",
diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb
index f259002b20..6a9ec1dc34 100644
--- a/spec/unit/knife/bootstrap/client_builder_spec.rb
+++ b/spec/unit/knife/bootstrap/client_builder_spec.rb
@@ -42,7 +42,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do
context "#sanity_check!" do
let(:response_404) { OpenStruct.new(code: "404") }
- let(:exception_404) { Net::HTTPServerException.new("404 not found", response_404) }
+ let(:exception_404) { Net::HTTPClientException.new("404 not found", response_404) }
context "in cases where the prompting fails" do
before do
diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb
index 7277b63c28..f65a26c455 100644
--- a/spec/unit/knife/cookbook_delete_spec.rb
+++ b/spec/unit/knife/cookbook_delete_spec.rb
@@ -139,15 +139,15 @@ describe Chef::Knife::CookbookDelete do
end
it "should raise if an error other than HTTP 404 is returned" do
- exception = Net::HTTPServerException.new("500 Internal Server Error", "500")
+ exception = Net::HTTPClientException.new("500 Internal Server Error", "500")
expect(@rest_mock).to receive(:get).and_raise(exception)
- expect { @knife.available_versions }.to raise_error Net::HTTPServerException
+ expect { @knife.available_versions }.to raise_error Net::HTTPClientException
end
describe "if the cookbook can't be found" do
before(:each) do
expect(@rest_mock).to receive(:get)
- .and_raise(Net::HTTPServerException.new("404 Not Found", "404"))
+ .and_raise(Net::HTTPClientException.new("404 Not Found", "404"))
end
it "should print an error" do
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index 6624fb70ab..d12f3398f3 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -63,7 +63,7 @@ describe Chef::Knife::DataBagCreate do
exception = double("404 error", code: "404")
allow(rest).to receive(:get)
.with("data/#{bag_name}")
- .and_raise(Net::HTTPServerException.new("404", exception))
+ .and_raise(Net::HTTPClientException.new("404", exception))
end
it "tries to create a data bag with an invalid name when given one argument" do
@@ -86,7 +86,7 @@ describe Chef::Knife::DataBagCreate do
%w{node role client environment}.each do |name|
allow(rest).to receive(:get)
.with("data/sudoing_#{name}_admins")
- .and_raise(Net::HTTPServerException.new("404", exception))
+ .and_raise(Net::HTTPClientException.new("404", exception))
end
end
diff --git a/spec/unit/knife/supermarket_share_spec.rb b/spec/unit/knife/supermarket_share_spec.rb
index dde58775f4..6601cdcd31 100644
--- a/spec/unit/knife/supermarket_share_spec.rb
+++ b/spec/unit/knife/supermarket_share_spec.rb
@@ -85,7 +85,7 @@ describe Chef::Knife::SupermarketShare do
it "should use a default category when given only 1 argument and cannot determine category" do
@knife.name_args = ["cookbook_name"]
- expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Net::HTTPServerException.new("404 Not Found", OpenStruct.new(code: "404")) }
+ expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Net::HTTPClientException.new("404 Not Found", OpenStruct.new(code: "404")) }
expect(@knife).to receive(:do_upload)
expect { @knife.run }.to_not raise_error
end
diff --git a/spec/unit/knife/supermarket_unshare_spec.rb b/spec/unit/knife/supermarket_unshare_spec.rb
index 206717e211..5976297fb6 100644
--- a/spec/unit/knife/supermarket_unshare_spec.rb
+++ b/spec/unit/knife/supermarket_unshare_spec.rb
@@ -57,15 +57,15 @@ describe Chef::Knife::SupermarketUnshare do
it "should log an error and exit when forbidden" do
exception = double('403 "Forbidden"', code: "403")
- allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception))
+ allow(@rest).to receive(:delete).and_raise(Net::HTTPClientException.new('403 "Forbidden"', exception))
expect(@knife.ui).to receive(:error)
expect { @knife.run }.to raise_error(SystemExit)
end
it "should re-raise any non-forbidden errors on delete" do
exception = double('500 "Application Error"', code: "500")
- allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception))
- expect { @knife.run }.to raise_error(Net::HTTPServerException)
+ allow(@rest).to receive(:delete).and_raise(Net::HTTPClientException.new('500 "Application Error"', exception))
+ expect { @knife.run }.to raise_error(Net::HTTPClientException)
end
it "should log a success message" do
diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb
index c091286077..67251b2cd9 100644
--- a/spec/unit/knife_spec.rb
+++ b/spec/unit/knife_spec.rb
@@ -424,7 +424,7 @@ describe Chef::Knife do
response = Net::HTTPUnauthorized.new("1.1", "401", "Unauthorized")
response.instance_variable_set(:@read, true) # I hate you, net/http.
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no syncronize your clock?"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("401 Unauthorized", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("401 Unauthorized", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(/ERROR: Failed to authenticate to/)
expect(stderr.string).to match(/Response: y u no syncronize your clock\?/)
@@ -434,7 +434,7 @@ describe Chef::Knife do
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
response.instance_variable_set(:@read, true) # I hate you, net/http.
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
@@ -454,7 +454,7 @@ describe Chef::Knife do
response = Net::HTTPForbidden.new("1.1", "403", "Forbidden")
response.instance_variable_set(:@read, true)
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u no administrator"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("403 Forbidden", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("403 Forbidden", response))
allow(knife).to receive(:username).and_return("sadpanda")
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: You authenticated successfully to http.+ as sadpanda but you are not authorized for this action})
@@ -467,7 +467,7 @@ describe Chef::Knife do
response = Net::HTTPBadRequest.new("1.1", "400", "Bad Request")
response.instance_variable_set(:@read, true) # I hate you, net/http.
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "y u search wrong"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("400 Bad Request", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("400 Bad Request", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: The data in your request was invalid})
expect(stderr.string).to match(%r{Response: y u search wrong})
@@ -477,7 +477,7 @@ describe Chef::Knife do
response = Net::HTTPNotFound.new("1.1", "404", "Not Found")
response.instance_variable_set(:@read, true) # I hate you, net/http.
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nothing to see here"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("404 Not Found", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("404 Not Found", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: The object you are looking for could not be found})
expect(stderr.string).to match(%r{Response: nothing to see here})
@@ -491,7 +491,7 @@ describe Chef::Knife do
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))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("406 Not Acceptable", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to include("The request that Knife sent was using API version 10000000")
@@ -533,7 +533,7 @@ describe Chef::Knife do
response = Net::HTTPPaymentRequired.new("1.1", "402", "Payment Required")
response.instance_variable_set(:@read, true) # I hate you, net/http.
allow(response).to receive(:body).and_return(Chef::JSONCompat.to_json(error: "nobugfixtillyoubuy"))
- allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("402 Payment Required", response))
+ allow(knife).to receive(:run).and_raise(Net::HTTPClientException.new("402 Payment Required", response))
knife.run_with_pretty_exceptions
expect(stderr.string).to match(%r{ERROR: Payment Required})
expect(stderr.string).to match(%r{Response: nobugfixtillyoubuy})
diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb
index cabc85439c..f3b3fa14ab 100644
--- a/spec/unit/mixin/api_version_request_handling_spec.rb
+++ b/spec/unit/mixin/api_version_request_handling_spec.rb
@@ -27,7 +27,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when the response code is not 406" do
let(:response) { OpenStruct.new(code: "405") }
- let(:exception) { Net::HTTPServerException.new("405 Something Else", response) }
+ let(:exception) { Net::HTTPClientException.new("405 Something Else", response) }
it "returns nil" do
expect(object.server_client_api_version_intersection(exception, default_supported_client_versions))
@@ -38,7 +38,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do
context "when the response code is 406" do
let(:response) { OpenStruct.new(code: "406") }
- let(:exception) { Net::HTTPServerException.new("406 Not Acceptable", response) }
+ let(:exception) { Net::HTTPClientException.new("406 Not Acceptable", response) }
context "when x-ops-server-api-version header does not exist" do
it "returns nil" do
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index ff912ee7a6..4c056ca349 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -53,7 +53,7 @@ describe Chef::Node do
describe "when the node does not exist on the server" do
before do
response = OpenStruct.new(code: "404")
- exception = Net::HTTPServerException.new("404 not found", response)
+ exception = Net::HTTPClientException.new("404 not found", response)
allow(Chef::Node).to receive(:load).and_raise(exception)
node.name("created-node")
end
@@ -1447,7 +1447,7 @@ describe Chef::Node do
node.name("monkey")
allow(node).to receive(:data_for_save).and_return({})
exception = double("404 error", code: "404")
- expect(@rest).to receive(:put).and_raise(Net::HTTPServerException.new("foo", exception))
+ expect(@rest).to receive(:put).and_raise(Net::HTTPClientException.new("foo", exception))
expect(@rest).to receive(:post).with("nodes", {})
node.save
end
diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb
index ab2fdecfe7..f22e2a74b3 100644
--- a/spec/unit/policy_builder/policyfile_spec.rb
+++ b/spec/unit/policy_builder/policyfile_spec.rb
@@ -218,7 +218,7 @@ describe Chef::PolicyBuilder::Policyfile do
end
context "when the deployment group cannot be loaded" do
- let(:error404) { Net::HTTPServerException.new("404 message", :body) }
+ let(:error404) { Net::HTTPClientException.new("404 message", :body) }
before do
expect(api_service).to receive(:get)
@@ -738,7 +738,7 @@ describe Chef::PolicyBuilder::Policyfile do
shared_examples "fetching cookbooks when they don't exist" do
context "and a cookbook is missing" do
- let(:error404) { Net::HTTPServerException.new("404 message", :body) }
+ let(:error404) { Net::HTTPClientException.new("404 message", :body) }
before do
policy_builder.finish_load_node(node)
diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb
index 1afc95fa48..e105f84bd3 100644
--- a/spec/unit/provider/remote_file/content_spec.rb
+++ b/spec/unit/provider/remote_file/content_spec.rb
@@ -161,7 +161,7 @@ describe Chef::Provider::RemoteFile::Content do
# https://github.com/chef/chef/pull/1358#issuecomment-40853299
def create_exception(exception_class)
- if [ Net::HTTPServerException, Net::HTTPFatalError ].include? exception_class
+ if [ Net::HTTPClientException, Net::HTTPFatalError ].include? exception_class
exception_class.new("message", { "something" => 1 })
else
exception_class.new
@@ -177,7 +177,7 @@ describe Chef::Provider::RemoteFile::Content do
Errno::ENOENT,
Errno::EACCES,
Timeout::Error,
- Net::HTTPServerException,
+ Net::HTTPClientException,
Net::HTTPFatalError,
Net::FTPError,
Errno::ETIMEDOUT,
diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb
index c532ba0ae9..cec931dd70 100644
--- a/spec/unit/resource_reporter_spec.rb
+++ b/spec/unit/resource_reporter_spec.rb
@@ -494,7 +494,7 @@ describe Chef::ResourceReporter do
@node = Chef::Node.new
@node.name("spitfire")
@exception = ArgumentError.new
- allow(@exception).to receive(:inspect).and_return("Net::HTTPServerException")
+ allow(@exception).to receive(:inspect).and_return("Net::HTTPClientException")
allow(@exception).to receive(:message).and_return("Object not found")
allow(@exception).to receive(:backtrace).and_return(@backtrace)
@resource_reporter.run_list_expand_failed(@node, @exception)
@@ -505,7 +505,7 @@ describe Chef::ResourceReporter do
it "includes the exception type in the event data" do
expect(@report).to have_key("data")
expect(@report["data"]["exception"]).to have_key("class")
- expect(@report["data"]["exception"]["class"]).to eq("Net::HTTPServerException")
+ expect(@report["data"]["exception"]["class"]).to eq("Net::HTTPClientException")
end
it "includes the exception message in the event data" do
@@ -615,7 +615,7 @@ describe Chef::ResourceReporter do
before do
# 404 getting the run_id
@response = Net::HTTPNotFound.new("a response body", "404", "Not Found")
- @error = Net::HTTPServerException.new("404 message", @response)
+ @error = Net::HTTPClientException.new("404 message", @response)
expect(@rest_client).to receive(:post)
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id,
start_time: @start_time.to_s },
@@ -645,7 +645,7 @@ describe Chef::ResourceReporter do
before do
# 500 getting the run_id
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
- @error = Net::HTTPServerException.new("500 message", @response)
+ @error = Net::HTTPClientException.new("500 message", @response)
expect(@rest_client).to receive(:post)
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
{ "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
@@ -675,7 +675,7 @@ describe Chef::ResourceReporter do
Chef::Config[:enable_reporting_url_fatals] = true
# 500 getting the run_id
@response = Net::HTTPInternalServerError.new("a response body", "500", "Internal Server Error")
- @error = Net::HTTPServerException.new("500 message", @response)
+ @error = Net::HTTPClientException.new("500 message", @response)
expect(@rest_client).to receive(:post)
.with("reports/nodes/spitfire/runs", { action: :start, run_id: @run_id, start_time: @start_time.to_s },
{ "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION })
@@ -690,7 +690,7 @@ describe Chef::ResourceReporter do
expect(Chef::Log).to receive(:error).with(/500/)
expect do
@resource_reporter.run_started(@run_status)
- end.to raise_error(Net::HTTPServerException)
+ end.to raise_error(Net::HTTPClientException)
end
end
@@ -746,7 +746,7 @@ describe Chef::ResourceReporter do
it "should log 4xx errors" do
response = Net::HTTPClientError.new("forbidden", "403", "Forbidden")
- error = Net::HTTPServerException.new("403 message", response)
+ error = Net::HTTPClientException.new("403 message", response)
allow(@rest_client).to receive(:raw_request).and_raise(error)
expect(Chef::Log).to receive(:error).with(/403/)
diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb
index 074a68840e..37b2252492 100644
--- a/spec/unit/user_v1_spec.rb
+++ b/spec/unit/user_v1_spec.rb
@@ -312,7 +312,7 @@ describe Chef::UserV1 do
describe "Versioned API Interactions" do
let(:response_406) { OpenStruct.new(code: "406") }
- let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
+ let(:exception_406) { Net::HTTPClientException.new("406 Not Acceptable", response_406) }
before (:each) do
@user = Chef::UserV1.new
@@ -374,7 +374,7 @@ describe Chef::UserV1 do
context "when the server returns a 400" do
let(:response_400) { OpenStruct.new(code: "400") }
- let(:exception_400) { Net::HTTPServerException.new("400 Bad Request", response_400) }
+ let(:exception_400) { Net::HTTPClientException.new("400 Bad Request", response_400) }
context "when the 400 was due to public / private key fields no longer being supported" do
let(:response_body_400) { '{"error":["Since Server API v1, all keys must be updated via the keys endpoint. "]}' }