diff options
author | Noah Kantrowitz <noah@coderanger.net> | 2017-11-27 15:13:42 -0500 |
---|---|---|
committer | Noah Kantrowitz <noah@coderanger.net> | 2017-11-27 15:13:42 -0500 |
commit | 9a202caafbb726dafc654012c2289b7fab616da4 (patch) | |
tree | c66e64b0908665dcefacaa65e44ae7b056a2ffcd /spec/unit/knife | |
parent | 5e38dd081fddd17643140442e18ce402ffb30ac7 (diff) | |
download | chef-9a202caafbb726dafc654012c2289b7fab616da4.tar.gz |
Forgot to check for a unit test. Sigh.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
Diffstat (limited to 'spec/unit/knife')
-rw-r--r-- | spec/unit/knife/data_bag_show_spec.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb index ece7f5bf78..8dd0669993 100644 --- a/spec/unit/knife/data_bag_show_spec.rb +++ b/spec/unit/knife/data_bag_show_spec.rb @@ -91,12 +91,11 @@ qux: http://localhost:4000/data/bag_o_data/qux} context "Data bag to show is not encrypted" do before do allow(knife).to receive(:encrypted?).and_return(false) - expect(knife).to receive(:read_secret).exactly(0).times end it "displays the data bag" do + expect(knife).to receive(:read_secret).exactly(0).times expect(Chef::DataBagItem).to receive(:load).with(bag_name, item_name).and_return(data_bag) - expect(knife.ui).to receive(:warn).with("Unencrypted data bag detected, ignoring any provided secret options.") expected = %q{baz: http://localhost:4000/data/bag_o_data/baz id: id @@ -104,6 +103,21 @@ qux: http://localhost:4000/data/bag_o_data/qux} knife.run expect(stdout.string.strip).to eq(expected) end + + context "when a secret is given" do + it "displays the data bag" do + expect(knife).to receive(:encryption_secret_provided_ignore_encrypt_flag?).and_return(true) + expect(knife).to receive(:read_secret).and_return(secret) + expect(Chef::DataBagItem).to receive(:load).with(bag_name, item_name).and_return(data_bag) + expect(knife.ui).to receive(:warn).with("Unencrypted data bag detected, ignoring any provided secret options.") + + expected = %q{baz: http://localhost:4000/data/bag_o_data/baz +id: id +qux: http://localhost:4000/data/bag_o_data/qux} + knife.run + expect(stdout.string.strip).to eq(expected) + end + end end it "displays the list of items in the data bag when only one @name_arg is provided" do |