summaryrefslogtreecommitdiff
path: root/spec/unit/knife
diff options
context:
space:
mode:
authorSandra Tiffin <sandi.tiffin@gmail.com>2017-10-03 14:34:42 -0700
committerSandra Tiffin <sandi.tiffin@gmail.com>2017-10-04 03:32:46 -0700
commit4cc81ce45ea0e7b851c622d8a18b33e1177b85cb (patch)
tree1cb89d5c2ac3824066e4716f2c7e5d1286b87ca2 /spec/unit/knife
parent838056df40c799f4c0f523b777de3c21506d7945 (diff)
downloadchef-4cc81ce45ea0e7b851c622d8a18b33e1177b85cb.tar.gz
Don't allow creation of data bags named node, role, client or environment.
Signed-off-by: Sandra Tiffin <sandi.tiffin@gmail.com>
Diffstat (limited to 'spec/unit/knife')
-rw-r--r--spec/unit/knife/data_bag_create_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb
index b7d185a58c..b295f0d715 100644
--- a/spec/unit/knife/data_bag_create_spec.rb
+++ b/spec/unit/knife/data_bag_create_spec.rb
@@ -72,6 +72,14 @@ describe Chef::Knife::DataBagCreate do
expect { knife.run }.to exit_with_code(1)
end
+ it "won't create a data bag with a reserved name for search" do
+ ['node', 'role', 'client', 'environment'].each do |name|
+ knife.name_args = [name]
+ expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName)
+ expect { knife.run }.to exit_with_code(1)
+ end
+ end
+
context "when given one argument" do
before do
knife.name_args = [bag_name]