diff options
author | Seth Falcon <seth@opscode.com> | 2011-06-01 17:35:26 -0700 |
---|---|---|
committer | Seth Falcon <seth@opscode.com> | 2011-06-01 17:35:26 -0700 |
commit | ee287c9d336cd90a81d9ed98bf2826e1c1886285 (patch) | |
tree | 76c866cef278d077638e3c465c7348fc279aadc1 | |
parent | f91da526e558845344c8b443f584587c726a19f9 (diff) | |
parent | 1b93de2fd4604630ec45bffe875df3d3d8d2e3bf (diff) | |
download | chef-ee287c9d336cd90a81d9ed98bf2826e1c1886285.tar.gz |
Merge branch 'CHEF-2396'
-rw-r--r-- | chef/lib/chef/encrypted_data_bag_item.rb | 4 | ||||
-rw-r--r-- | chef/spec/unit/encrypted_data_bag_item_spec.rb | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/chef/lib/chef/encrypted_data_bag_item.rb b/chef/lib/chef/encrypted_data_bag_item.rb index 98f64aa3c2..048ab8d57e 100644 --- a/chef/lib/chef/encrypted_data_bag_item.rb +++ b/chef/lib/chef/encrypted_data_bag_item.rb @@ -1,6 +1,6 @@ # # Author:: Seth Falcon (<seth@opscode.com>) -# Copyright:: Copyright 2010 Opscode, Inc. +# Copyright:: Copyright 2010-2011 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,7 +57,7 @@ class Chef::EncryptedDataBagItem def [](key) value = @enc_hash[key] - if key == "id" + if key == "id" || value.nil? value else self.class.decrypt_value(value, @secret) diff --git a/chef/spec/unit/encrypted_data_bag_item_spec.rb b/chef/spec/unit/encrypted_data_bag_item_spec.rb index a567768264..975c1318ef 100644 --- a/chef/spec/unit/encrypted_data_bag_item_spec.rb +++ b/chef/spec/unit/encrypted_data_bag_item_spec.rb @@ -1,6 +1,6 @@ # # Author:: Seth Falcon (<seth@opscode.com>) -# Copyright:: Copyright 2010 Opscode, Inc. +# Copyright:: Copyright 2010-2011 Opscode, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,6 +75,10 @@ describe Chef::EncryptedDataBagItem do it "decrypts everyting via to_hash" do @eh.to_hash.should == @plain_data end + + it "handles missing keys gracefully" do + @eh["no-such-key"].should be_nil + end end describe "loading" do |