summaryrefslogtreecommitdiff
path: root/spec/unit/knife
diff options
context:
space:
mode:
authorRyan Cragun <me@ryan.ec>2015-05-01 17:09:22 -0700
committerRyan Cragun <me@ryan.ec>2015-05-01 17:09:22 -0700
commitb5ae23df27d6dd2922d40309f6c1c23e97da4bb5 (patch)
tree4a227f0495e60177eda1f9ae9f09bbcf852f6d6b /spec/unit/knife
parente2b7e4e76cd8dae088299137d991a0455d87a109 (diff)
downloadchef-b5ae23df27d6dd2922d40309f6c1c23e97da4bb5.tar.gz
Enforce passing a node name when bootstrapping with chef-vault or userryan/validatorless_bootstrap
credentials When bootstrapping with chef-vault or with user credentials we create the node and client on the Chef Server before we bootstrap the node. As it is possible to specify a server address that is not the node name we need to enforce that the user pass a node name with -N.
Diffstat (limited to 'spec/unit/knife')
-rw-r--r--spec/unit/knife/bootstrap_spec.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index f1ca510ed3..aaace60f6a 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -531,6 +531,7 @@ describe Chef::Knife::Bootstrap do
describe "when running the bootstrap" do
let(:knife_ssh) do
knife.name_args = ["foo.example.com"]
+ knife.config[:chef_node_name] = "foo.example.com"
knife.config[:ssh_user] = "rooty"
knife.config[:identity_file] = "~/.ssh/me.rsa"
allow(knife).to receive(:render_template).and_return("")
@@ -590,6 +591,12 @@ describe Chef::Knife::Bootstrap do
expect(knife.chef_vault_handler).not_to receive(:run).with(node_name: knife.config[:chef_node_name])
knife.run
end
+
+ it "raises an exception if the config[:chef_node_name] is not present" do
+ knife.config[:chef_node_name] = nil
+
+ expect { knife.run }.to raise_error(SystemExit)
+ end
end
context "when the validation key is not present" do
@@ -604,6 +611,12 @@ describe Chef::Knife::Bootstrap do
expect(knife.chef_vault_handler).to receive(:run).with(node_name: knife.config[:chef_node_name])
knife.run
end
+
+ it "raises an exception if the config[:chef_node_name] is not present" do
+ knife.config[:chef_node_name] = nil
+
+ expect { knife.run }.to raise_error(SystemExit)
+ end
end
context "when the validation_key is nil" do