diff options
author | Anshul Sharma <justanshulsharma@gmail.com> | 2014-08-19 19:45:02 +0000 |
---|---|---|
committer | tyler-ball <tyleraball@gmail.com> | 2014-09-29 08:31:07 -0700 |
commit | 92e83b3a4de78e4273b23d0c0f737c43755aff59 (patch) | |
tree | 2fa50b550452ab713a393b7862fb999776ae7333 /spec/unit/knife/data_bag_create_spec.rb | |
parent | 4623c6a7f504bbac9a1a847ba3c16f17d9a7e5cf (diff) | |
download | chef-92e83b3a4de78e4273b23d0c0f737c43755aff59.tar.gz |
rspec test
Diffstat (limited to 'spec/unit/knife/data_bag_create_spec.rb')
-rw-r--r-- | spec/unit/knife/data_bag_create_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb index 2656b2b9b4..606d018a3c 100644 --- a/spec/unit/knife/data_bag_create_spec.rb +++ b/spec/unit/knife/data_bag_create_spec.rb @@ -72,6 +72,37 @@ describe Chef::Knife::DataBagCreate do @knife.run end + it "should not create an encrypted data bag item via --secret" do + @knife.name_args = ['sudoing_admins', 'ME'] + plain_data = {'login_name' => 'alphaomega', 'id' => 'ME'} + data_bag_item = Chef::DataBagItem.from_hash(plain_data) + data_bag_item.data_bag('sudoing_admins') + @knife.should_receive(:create_object).and_yield(plain_data) + @rest.should_receive(:post_rest).with('data', {'name' => 'sudoing_admins'}).ordered + @rest.should_receive(:post_rest).with('data/sudoing_admins', data_bag_item).ordered + secret = 'abc123SECRET' + @knife.stub(:config).and_return({:secret => secret}) + @knife.run + end + + it "should not create an encrypted data bag item via --secret_file " do + secret = 'abc123SECRET' + secret_file = Tempfile.new('encrypted_data_bag_secret_file_test') + secret_file.puts(secret) + secret_file.flush + @knife.name_args = ['sudoing_admins', 'ME'] + plain_data = {'login_name' => 'alphaomega', 'id' => 'ME'} + data_bag_item = Chef::DataBagItem.from_hash(plain_data) + data_bag_item.data_bag("sudoing_admins") + @knife.should_receive(:create_object).and_yield(plain_data) + @knife.stub(:config).and_return({:secret_file => secret_file.path}) + @rest.should_receive(:post_rest).with('data', {'name' => 'sudoing_admins'}).ordered + @rest.should_receive(:post_rest).with('data/sudoing_admins', data_bag_item).ordered + @knife.run + secret_file.close + secret_file.unlink + end + describe "encrypted data bag items" do before(:each) do @secret = "abc123SECRET" |