summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2018-03-14 15:20:47 +0000
committerGitHub <noreply@github.com>2018-03-14 15:20:47 +0000
commite20de6e6a79d0e16d4acc4f6eb7b6edebfaf4779 (patch)
treeda0324c197e074f33b83f1159311366b9fc2cddf
parentadf7574a076056a46325d5e764b9878793295d60 (diff)
downloadchef-e20de6e6a79d0e16d4acc4f6eb7b6edebfaf4779.tar.gz
Revert "Knife should give a useful error when the chef_server_url isn't a chef server API"revert-6253-feat/5556
-rw-r--r--.gitignore2
-rw-r--r--lib/chef/exceptions.rb2
-rw-r--r--lib/chef/knife.rb2
-rw-r--r--lib/chef/server_api.rb16
-rw-r--r--spec/unit/server_api_spec.rb30
5 files changed, 0 insertions, 52 deletions
diff --git a/.gitignore b/.gitignore
index 5cbf0c66eb..71f9cce719 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,8 +56,6 @@ vendor/
acceptance/vendor
kitchen-tests/vendor
-*.swp
-
# Visual Studio Code files
.vscode
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index cd825895b0..1ed71d2a55 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -521,7 +521,5 @@ This error is most often caused by network issues (proxies, etc) outside of chef
# exception specific to invalid usage of 'dsc_resource' resource
class DSCModuleNameMissing < ArgumentError; end
-
- class NotAChefServerException < ArgumentError; end
end
end
diff --git a/lib/chef/knife.rb b/lib/chef/knife.rb
index 49b4b50cd7..4e975c2b27 100644
--- a/lib/chef/knife.rb
+++ b/lib/chef/knife.rb
@@ -475,8 +475,6 @@ class Chef
when Chef::Exceptions::InvalidRedirect
ui.error "Invalid Redirect: #{e.message}"
ui.info "Change your server location in knife.rb to the server's FQDN to avoid unwanted redirections."
- when Chef::Exceptions::NotAChefServerException
- ui.error "#{Chef::Config[:chef_server_url]} is not a valid chef server"
else
ui.error "#{e.class.name}: #{e.message}"
end
diff --git a/lib/chef/server_api.rb b/lib/chef/server_api.rb
index d539ed5fed..c501544954 100644
--- a/lib/chef/server_api.rb
+++ b/lib/chef/server_api.rb
@@ -25,7 +25,6 @@ require "chef/http/json_output"
require "chef/http/remote_request_id"
require "chef/http/validate_content_length"
require "chef/http/api_versions"
-require "ffi_yajl"
class Chef
class ServerAPI < Chef::HTTP
@@ -58,21 +57,6 @@ class Chef
alias :post_rest :post
alias :put_rest :put
- def get(path, headers = {})
- request(:GET, path, headers)
- rescue Net::HTTPServerException => e
- if e.response.kind_of?(Net::HTTPNotFound)
- begin
- FFI_Yajl::Parser.parse(e.response.body)
- rescue FFI_Yajl::ParseError => e
- raise Chef::Exceptions::NotAChefServerException
- end
- raise
- else
- raise
- end
- end
-
# Makes an HTTP request to +path+ with the given +method+, +headers+, and
# +data+ (if applicable). Does not apply any middleware, besides that
# needed for Authentication.
diff --git a/spec/unit/server_api_spec.rb b/spec/unit/server_api_spec.rb
index c64f42d358..3f1d9b0e90 100644
--- a/spec/unit/server_api_spec.rb
+++ b/spec/unit/server_api_spec.rb
@@ -58,36 +58,6 @@ describe Chef::ServerAPI do
end
end
- describe "#get" do
- context "when response is 404" do
- context "body data is not json" do
- it "throws not a Chef server exception" do
- net_http_not_found = double()
- allow(net_http_not_found).to receive(:kind_of?).and_return(Net::HTTPNotFound)
- allow(net_http_not_found).to receive(:body).and_return("Not Found")
-
- api = described_class.new(url, raw_key: SIGNING_KEY_DOT_PEM)
- allow(api).to receive(:request).and_raise(Net::HTTPServerException.new("", net_http_not_found))
-
- expect { api.get("/nodes") }.to raise_error(Chef::Exceptions::NotAChefServerException)
- end
- end
-
- context "body data is json" do
- it "bubbles up Exception" do
- net_http_not_found = double()
- allow(net_http_not_found).to receive(:kind_of?).and_return(Net::HTTPNotFound)
- allow(net_http_not_found).to receive(:body).and_return("{}")
-
- api = described_class.new(url, raw_key: SIGNING_KEY_DOT_PEM)
- allow(api).to receive(:request).and_raise(Net::HTTPServerException.new("", net_http_not_found))
-
- expect { api.get("/nodes") }.to raise_error(Net::HTTPServerException)
- end
- end
- end
- end
-
context "versioned apis" do
class VersionedClassV0
extend Chef::Mixin::VersionedAPI