File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -899,6 +899,39 @@ def expect_empty_list(user_headers)
899899 expect ( response ) . to include ( 'detail' => 'Service broker not found' )
900900 end
901901 end
902+
903+ context 'when the encryption_key_label is invalid' do
904+ let ( :broker ) { VCAP ::CloudController ::ServiceBroker . make }
905+ let ( :api_call ) do
906+ lambda { |headers |
907+ patch "/v3/service_brokers/#{ broker . guid } " , { authentication : {
908+ type : 'basic' ,
909+ credentials : {
910+ username : 'your-username' ,
911+ password : 'your-password'
912+ }
913+ } } . to_json , headers
914+ }
915+ end
916+
917+ before do
918+ VCAP ::CloudController ::Encryptor . database_encryption_keys = {
919+ encryption_key_0 : 'somevalidkeyvalue' ,
920+ foo : 'fooencryptionkey' ,
921+ death : 'headbangingdeathmetalkey' , 'invalid-key-label' : 'fakekey'
922+ }
923+ broker . class . db [ :service_brokers ] . where ( id : broker . id ) . update ( encryption_key_label : 'invalid-key-label' )
924+ allow ( VCAP ::CloudController ::Encryptor ) . to receive ( :run_cipher ) . and_raise ( OpenSSL ::Cipher ::CipherError )
925+ allow_any_instance_of ( ErrorPresenter ) . to receive ( :raise_500? ) . and_return ( false )
926+ end
927+
928+ it 'fails to decrypt the broker data and returns a 500 error' do
929+ api_call . call ( admin_headers )
930+
931+ expect ( last_response ) . to have_status_code ( 500 )
932+ expect ( parsed_response [ 'errors' ] . first [ 'detail' ] ) . to match ( /Failed/i )
933+ end
934+ end
902935 end
903936
904937 describe 'POST /v3/service_brokers' do
You can’t perform that action at this time.
0 commit comments