summaryrefslogtreecommitdiff
path: root/spec
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 /spec
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 'spec')
-rw-r--r--spec/unit/server_api_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/unit/server_api_spec.rb b/spec/unit/server_api_spec.rb
index 05d2a28ed4..79ca564793 100644
--- a/spec/unit/server_api_spec.rb
+++ b/spec/unit/server_api_spec.rb
@@ -31,6 +31,11 @@ Y6S6MeZ69Rp89ma4ttMZ+kwi1+XyHqC/dlcVRW42Zl5Dc7BALRlJjQ==
describe Chef::ServerAPI do
let(:url) { "http://chef.example.com:4000" }
let(:key_path) { "/tmp/foo" }
+ let(:org_data) { { "name" => "some_name", "full_name" => "some_full_name", "guid" => "abc1223" } }
+
+ before(:each) do
+ allow_any_instance_of(described_class).to receive(:get).with("/").and_return(org_data)
+ end
describe "#initialize" do
it "uses the configured key file" do
@@ -46,5 +51,12 @@ describe Chef::ServerAPI do
expect(api.options[:signing_key_filename]).to be_nil
expect(api.options[:raw_key]).to eql(SIGNING_KEY_DOT_PEM)
end
+
+ context "when url is not a chef server" do
+ let(:org_data) { Hash.new }
+ it "throws exception" do
+ expect{ described_class.new(url, raw_key: SIGNING_KEY_DOT_PEM) }.to raise_exception(Chef::Exceptions::NotAChefServerException)
+ end
+ end
end
end