File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33983398 end
33993399 end
34003400 end
3401+
3402+ context 'when the encryption_key_label is invalid' do
3403+ let ( :instance ) { VCAP ::CloudController ::ManagedServiceInstance . make ( space :) }
3404+ let ( :app_binding ) do
3405+ VCAP ::CloudController ::ServiceBinding . make (
3406+ app : app_model ,
3407+ service_instance_guid : instance . guid ,
3408+ credentials : { key : 'value' } ,
3409+ syslog_drain_url : 'syslog-url' ,
3410+ volume_mounts : %w[ volume1 volume2 ]
3411+ )
3412+ end
3413+
3414+ before do
3415+ VCAP ::CloudController ::Encryptor . database_encryption_keys = {
3416+ encryption_key_0 : 'somevalidkeyvalue' ,
3417+ foo : 'fooencryptionkey' ,
3418+ death : 'headbangingdeathmetalkey' , 'invalid-key-label' : 'fakekey'
3419+ }
3420+ allow_any_instance_of ( ErrorPresenter ) . to receive ( :raise_500? ) . and_return ( false )
3421+ end
3422+
3423+ it 'fails to decrypt the environment variables and returns a 500 error' do
3424+ app_binding . class . db [ :service_bindings ] . where ( id : app_binding . id ) . update ( encryption_key_label : 'invalid-key-label' )
3425+
3426+ allow ( VCAP ::CloudController ::Encryptor ) . to receive ( :run_cipher ) . and_raise ( OpenSSL ::Cipher ::CipherError )
3427+ api_call . call ( admin_headers )
3428+
3429+ expect ( last_response ) . to have_status_code ( 500 )
3430+ expect ( parsed_response [ 'errors' ] . first [ 'detail' ] ) . to match ( /Failed/i )
3431+ end
3432+ end
34013433 end
34023434
34033435 describe 'GET /v3/apps/:guid/permissions' do
You can’t perform that action at this time.
0 commit comments