diff options
author | danielsdeleo <dan@opscode.com> | 2013-04-26 17:02:05 -0700 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-04-26 17:02:05 -0700 |
commit | 69dca6431c682fe0226805510e67d1be3cbf2af8 (patch) | |
tree | 861bf6a3a96d08c4b14f7408f6526453a3739ed6 /spec/unit/encrypted_data_bag_item_spec.rb | |
parent | 451b7fb16fbc36b8a6391fec54474fc7d26f160c (diff) | |
download | chef-69dca6431c682fe0226805510e67d1be3cbf2af8.tar.gz |
[CHEF-3858] rescue bad json errors and re-raise as decryption failures
Diffstat (limited to 'spec/unit/encrypted_data_bag_item_spec.rb')
-rw-r--r-- | spec/unit/encrypted_data_bag_item_spec.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 272846d659..034868b01d 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -92,6 +92,17 @@ describe Chef::EncryptedDataBagItem::Decryptor do decryptor.for_decrypted_item.should eq plaintext_data end + describe "and the decryption step returns invalid data" do + it "raises a decryption failure error" do + # Over a large number of tests on a variety of systems, we occasionally + # see the decryption step "succeed" but return invalid data (e.g., not + # the original plain text) [CHEF-3858] + decryptor.should_receive(:decrypted_data).and_return("lksajdf") + lambda { decryptor.for_decrypted_item }.should raise_error(Chef::EncryptedDataBagItem::DecryptionFailure) + end + + end + context "and the provided key is incorrect" do let(:decryption_key) { "wrong-passwd" } |