summaryrefslogtreecommitdiff
path: root/spec/unit
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2019-05-17 15:34:52 -0400
committerBryan McLellan <btm@loftninjas.org>2019-05-17 15:35:48 -0400
commitf5f0f730969255851bd7e9f57a421e791b8bd034 (patch)
treedf46367372d8198309100e16282569fdc4975952 /spec/unit
parent7bb95d133a81af47e70a018cd6081da2f9f87dc8 (diff)
downloadchef-f5f0f730969255851bd7e9f57a421e791b8bd034.tar.gz
Only set client_pem in bootstrap_context when validatorlessbtm/client_key_validator_fix
We should only set bootstrap_context.client_pem if we're a validatorless bootstrap. Fixes #8534 Signed-off-by: Bryan McLellan <btm@loftninjas.org>
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/knife/bootstrap_spec.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb
index 8467b6dc70..4a7286bd6f 100644
--- a/spec/unit/knife/bootstrap_spec.rb
+++ b/spec/unit/knife/bootstrap_spec.rb
@@ -1654,10 +1654,6 @@ describe Chef::Knife::Bootstrap do
end
end
describe "#run" do
- before do
- allow(knife.client_builder).to receive(:client_path).and_return("/key.pem")
- end
-
it "performs the steps we expect to run a bootstrap" do
expect(knife).to receive(:check_license)
expect(knife).to receive(:verify_deprecated_flags!).ordered
@@ -1678,7 +1674,6 @@ describe Chef::Knife::Bootstrap do
knife.run
# Post-run verify expected state changes (not many directly in #run)
- expect(knife.bootstrap_context.client_pem).to eq "/key.pem"
expect($stdout.sync).to eq true
end
end
@@ -1731,6 +1726,7 @@ describe Chef::Knife::Bootstrap do
let(:node_name) { "test" }
before do
allow(client_builder_mock).to receive(:client).and_return "client"
+ allow(client_builder_mock).to receive(:client_path).and_return "/key.pem"
end
it "runs client_builder and vault_handler" do
@@ -1738,6 +1734,13 @@ describe Chef::Knife::Bootstrap do
expect(vault_handler_mock).to receive(:run).with("client")
knife.register_client
end
+
+ it "sets the path to the client key in the bootstrap context" do
+ allow(client_builder_mock).to receive(:run)
+ allow(vault_handler_mock).to receive(:run).with("client")
+ knife.register_client
+ expect(knife.bootstrap_context.client_pem).to eq "/key.pem"
+ end
end
context "when no valid node name is present" do