summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2017-11-27 15:13:42 -0500
committerNoah Kantrowitz <noah@coderanger.net>2017-11-27 15:13:42 -0500
commit9a202caafbb726dafc654012c2289b7fab616da4 (patch)
treec66e64b0908665dcefacaa65e44ae7b056a2ffcd
parent5e38dd081fddd17643140442e18ce402ffb30ac7 (diff)
downloadchef-9a202caafbb726dafc654012c2289b7fab616da4.tar.gz
Forgot to check for a unit test. Sigh.
Signed-off-by: Noah Kantrowitz <noah@coderanger.net>
-rw-r--r--spec/integration/knife/data_bag_show_spec.rb7
-rw-r--r--spec/unit/knife/data_bag_show_spec.rb18
2 files changed, 16 insertions, 9 deletions
diff --git a/spec/integration/knife/data_bag_show_spec.rb b/spec/integration/knife/data_bag_show_spec.rb
index 473d03fba4..38dfd8730d 100644
--- a/spec/integration/knife/data_bag_show_spec.rb
+++ b/spec/integration/knife/data_bag_show_spec.rb
@@ -49,12 +49,5 @@ heavy: true
id: falcon9
EOM
end
-
- it "with a single item and a useless secret" do
- knife("data bag show rocket falcon9 --secret=mykey").should_succeed <<EOM, stderr: "WARNING: Unencrypted data bag detected, ignoring any provided secret options.\n"
-heavy: true
-id: falcon9
-EOM
- end
end
end
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