This repository was archived by the owner on Jun 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -216,6 +216,7 @@ def update_managed(service_instance)
216216 if message . service_plan_guid
217217 service_plan = ServicePlan . first ( guid : message . service_plan_guid )
218218 unprocessable_service_plan! unless service_plan_valid? ( service_plan , service_instance . space )
219+ invalid_service_plan_relation! unless service_plan . service == service_instance . service
219220 end
220221
221222 service_event_repository = VCAP ::CloudController ::Repositories ::ServiceEventRepository . new ( user_audit_info )
@@ -320,4 +321,8 @@ def unprocessable_service_plan!
320321 def broker_unavailable!
321322 unprocessable! ( 'The service instance cannot be created because there is an operation in progress for the service broker' )
322323 end
324+
325+ def invalid_service_plan_relation!
326+ raise CloudController ::Errors ::ApiError . new_from_details ( 'InvalidRelation' , 'service plan relates to a different service offering' )
327+ end
323328end
Original file line number Diff line number Diff line change @@ -1746,6 +1746,37 @@ def check_filtered_instances(*instances)
17461746 )
17471747 end
17481748 end
1749+
1750+ context 'service plan is relates to a different service offering' do
1751+ let! ( :service_instance ) do
1752+ VCAP ::CloudController ::ManagedServiceInstance . make (
1753+ tags : %w( foo bar ) ,
1754+ space : space
1755+ )
1756+ end
1757+ let ( :guid ) { service_instance . guid }
1758+ let ( :plan ) { VCAP ::CloudController ::ServicePlan . make }
1759+ let ( :request_body ) do
1760+ {
1761+ relationships : {
1762+ service_plan : {
1763+ data : {
1764+ guid : plan . guid
1765+ }
1766+ }
1767+ }
1768+ }
1769+ end
1770+
1771+ it 'should fail' do
1772+ api_call . call ( admin_headers )
1773+
1774+ expect ( last_response ) . to have_status_code ( 400 )
1775+ expect ( parsed_response [ 'errors' ] ) . to include (
1776+ include ( { 'detail' => include ( 'service plan relates to a different service offering' ) } )
1777+ )
1778+ end
1779+ end
17491780 end
17501781 end
17511782
You can’t perform that action at this time.
0 commit comments