diff options
author | Seth Chisamore <schisamo@opscode.com> | 2013-03-17 21:53:56 -0400 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2013-04-11 14:25:45 -0700 |
commit | 64b1a49d4a03916402df57197aa97485820b842d (patch) | |
tree | 54d5525eb21c6c7672267ed8361a56c82ce29bb5 /spec/unit/config_spec.rb | |
parent | 67ac0783ba83eb6c9c1259cb4d9fc8987a9eb15b (diff) | |
download | chef-64b1a49d4a03916402df57197aa97485820b842d.tar.gz |
[CHEF-4011] move default secret file path to Chef::Config
* Remove references to DEFAULT_SECRET_FILE from
`Chef::EncryptedDataBagItem`.
* Add new `:encrypted_data_bag_secret` value to `Chef::Config`
* Ensure Chef::Config[:encrypted_data_bag_secret] is nil if the secret
does not exist at the default path.
* Updated test coverage in `config_spec` and
`encrypted_data_bag_item_spec`.
Diffstat (limited to 'spec/unit/config_spec.rb')
-rw-r--r-- | spec/unit/config_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 7b5d383ba3..42809eec91 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -261,6 +261,33 @@ describe Chef::Config do end end + describe "Chef::Config[:encrypted_data_bag_secret]" do + db_secret_default_path = "/etc/chef/encrypted_data_bag_secret" + let(:db_secret_default_path){ db_secret_default_path } + + before do + File.stub(:exist?).with(db_secret_default_path).and_return(secret_exists) + # ugh...the only way to properly test this since the conditional + # is evaluated at file load/require time. + $LOADED_FEATURES.delete_if{|f| f =~ /chef\/config\.rb/} + require 'chef/config' + end + + context "#{db_secret_default_path} exists" do + let(:secret_exists) { true } + it "sets the value to #{db_secret_default_path}" do + Chef::Config[:encrypted_data_bag_secret].should eq db_secret_default_path + end + end + + context "#{db_secret_default_path} does not exist" do + let(:secret_exists) { false } + it "sets the value to nil" do + Chef::Config[:encrypted_data_bag_secret].should be_nil + end + end + end + after(:each) do Chef::Config.configuration = @original_config end |