|
641 | 641 | end |
642 | 642 | end |
643 | 643 |
|
| 644 | + describe 'GET /v3/service_route_bindings' do |
| 645 | + describe 'no bindings to list' do |
| 646 | + let(:api_call) { ->(user_headers) { get '/v3/service_route_bindings', nil, user_headers } } |
| 647 | + let(:expected_codes_and_responses) do |
| 648 | + Hash.new(code: 200, response_objects: []) |
| 649 | + end |
| 650 | + |
| 651 | + it_behaves_like 'permissions for list endpoint', ALL_PERMISSIONS |
| 652 | + end |
| 653 | + |
| 654 | + describe 'a mix of bindings' do |
| 655 | + let(:route) { VCAP::CloudController::Route.make(space: space) } |
| 656 | + let(:service_instance_1) { VCAP::CloudController::UserProvidedServiceInstance.make(:routing, space: space, route_service_url: route_service_url) } |
| 657 | + let(:service_instance_2) { VCAP::CloudController::ManagedServiceInstance.make(:routing, space: space, route_service_url: route_service_url) } |
| 658 | + let(:route_binding_1) do |
| 659 | + bind_service_to_route(service_instance_1, route) |
| 660 | + end |
| 661 | + let(:route_binding_2) do |
| 662 | + bind_service_to_route(service_instance_2, route) |
| 663 | + end |
| 664 | + let(:api_call) { ->(user_headers) { get '/v3/service_route_bindings', nil, user_headers } } |
| 665 | + let(:response_objects) do |
| 666 | + [ |
| 667 | + expected_json( |
| 668 | + binding_guid: route_binding_1.guid, |
| 669 | + route_service_url: route_service_url, |
| 670 | + service_instance_guid: service_instance_1.guid, |
| 671 | + route_guid: route.guid, |
| 672 | + last_operation_type: 'create', |
| 673 | + last_operation_state: 'successful', |
| 674 | + ), |
| 675 | + expected_json( |
| 676 | + binding_guid: route_binding_2.guid, |
| 677 | + route_service_url: route_service_url, |
| 678 | + service_instance_guid: service_instance_2.guid, |
| 679 | + route_guid: route.guid, |
| 680 | + last_operation_type: 'create', |
| 681 | + last_operation_state: 'successful', |
| 682 | + ) |
| 683 | + ] |
| 684 | + end |
| 685 | + let(:bindings_response_body) do |
| 686 | + { code: 200, response_objects: response_objects } |
| 687 | + end |
| 688 | + |
| 689 | + let(:expected_codes_and_responses) do |
| 690 | + Hash.new(code: 200, response_objects: []).tap do |h| |
| 691 | + h['admin'] = bindings_response_body |
| 692 | + h['admin_read_only'] = bindings_response_body |
| 693 | + h['global_auditor'] = bindings_response_body |
| 694 | + h['space_developer'] = bindings_response_body |
| 695 | + h['space_manager'] = bindings_response_body |
| 696 | + h['space_auditor'] = bindings_response_body |
| 697 | + h['org_manager'] = bindings_response_body |
| 698 | + end |
| 699 | + end |
| 700 | + |
| 701 | + it_behaves_like 'permissions for list endpoint', ALL_PERMISSIONS |
| 702 | + end |
| 703 | + end |
| 704 | + |
644 | 705 | describe 'GET /v3/service_route_bindings/:guid' do |
645 | 706 | let(:api_call) { ->(user_headers) { get "/v3/service_route_bindings/#{guid}", nil, user_headers } } |
646 | 707 | let(:route) { VCAP::CloudController::Route.make(space: space) } |
@@ -755,4 +816,12 @@ def expected_json(binding_guid:, route_service_url:, route_guid:, service_instan |
755 | 816 | } |
756 | 817 | } |
757 | 818 | end |
| 819 | + |
| 820 | + def bind_service_to_route(service_instance, route) |
| 821 | + route_service_url = service_instance.route_service_url |
| 822 | + VCAP::CloudController::RouteBinding.new.save_with_new_operation( |
| 823 | + { service_instance: service_instance, route: route, route_service_url: route_service_url }, |
| 824 | + { type: 'create', state: 'successful' } |
| 825 | + ) |
| 826 | + end |
758 | 827 | end |
0 commit comments