summaryrefslogtreecommitdiff
path: root/lib/chef/server_api.rb
diff options
context:
space:
mode:
authorJose Asuncion <jeunito@gmail.com>2017-07-04 15:35:05 -0700
committerJose Asuncion <jeunito@gmail.com>2017-07-04 20:18:58 -0700
commit02a46911341c1d5ef10309d27963031d598dbe2c (patch)
tree1ccc843c6d4c4d64c63e417086dacb1c0cd3bdea /lib/chef/server_api.rb
parent15d13582b0dbe78c20175cc6dc3d68d10f995505 (diff)
downloadchef-02a46911341c1d5ef10309d27963031d598dbe2c.tar.gz
raise error if chef_server_url is not valid
Signed-off-by: Jose Asuncion <jeunito@gmail.com>
Diffstat (limited to 'lib/chef/server_api.rb')
-rw-r--r--lib/chef/server_api.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/chef/server_api.rb b/lib/chef/server_api.rb
index 2bdc5d9fe8..3a98b7aa3a 100644
--- a/lib/chef/server_api.rb
+++ b/lib/chef/server_api.rb
@@ -25,6 +25,7 @@ require "chef/http/json_output"
require "chef/http/remote_request_id"
require "chef/http/validate_content_length"
require "chef/http/api_versions"
+require "chef/exceptions"
class Chef
class ServerAPI < Chef::HTTP
@@ -35,6 +36,9 @@ class Chef
options[:signing_key_filename] = nil if chef_zero_uri?(url)
options[:inflate_json_class] = false
super(url, options)
+
+ chef_server_attrs = get("/").keys.sort
+ raise Chef::Exceptions::NotAChefServerException if [ "guid", "full_name", "name" ].sort != chef_server_attrs
end
use Chef::HTTP::JSONInput