I should point out that, as of Chef 12, the `encrypted_data_bag_item` method in Chef Sugar is less useful, as the `data_bag_item` method that is built-in to Chef can now determine if a data bag item is encrypted or not, and act appropriately.
This means, for testing a cookbook, you can use plaintext versions of the data bag item(s) (i.e., in `test/integration/data_bags`), while keeping your real ones as encrypted items in your Chef Server.
On August 7, 2015 at 2:24:26 PM, Daniel Givens (
">
) wrote:
​Correction - encrypted_data_bag_secret config setting
From: Daniel
Givens
Sent: Friday, August 7, 2015 1:23 PM
To: chef
Subject: Re: [chef] Re: chefspec and chef-sugar
Yes, that works for doing it the "regular" way as I use that
method where I'm using other encrypted data bags, but I'm depending
on a cookbook that uses encrypted_data_bag_item
from chef-sugar. It relies on the encrypted_data_bag_item
config setting or else it throws an exception. That isn't set when
chefspec runs, so I'm thinking that I need to stub that method. I
just don't know how.
From: Yoshi Spendiff
<
>
Sent: Friday, August 7, 2015 1:02 PM
To: chef
Subject: [chef] Re: chefspec and chef-sugar
This is the example on the ChefSpec page:
If you are using Encrypted Data Bag Items,
you'll need to dive into the RSpec layer and stub that class method
instead:
describe 'example::default' do
before do
allow(Chef::EncryptedDataBagItem).to receive(:load).with('users', 'svargo').and_return(...)
end
end
I've not actually done it, but in your case maybe something along
these lines?
allow(Chef::EncryptedDataBagItem).to receive(:load).with('ssl', 'dhparam', 'not_nil').and_return(
'parameters' => 'parameters'
)
|