Skip to content

Commit

Permalink
Minor refactor of v2 endpoints (#4140)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethboyles authored Dec 19, 2024
1 parent 2868f02 commit 8e1672b
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 38 deletions.
12 changes: 0 additions & 12 deletions app/controllers/services/managed_service_instances_controller.rb

This file was deleted.

6 changes: 6 additions & 0 deletions app/controllers/services/service_instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require 'presenters/v2/service_instance_shared_from_presenter'

module VCAP::CloudController
# rubocop:disable Metrics/ClassLength
class ServiceInstancesController < RestController::ModelController
include VCAP::CloudController::LockCheck

Expand Down Expand Up @@ -142,6 +143,10 @@ def update(guid)
raise CloudController::Errors::ApiError.new_from_details('AsyncServiceBindingOperationInProgress', e.service_binding.app.name, e.service_binding.service_instance.name)
end

deprecated_endpoint '/v2/managed_service_instances'
get '/v2/managed_service_instances', :enumerate
get '/v2/managed_service_instances/:guid', :read

def read(guid)
service_instance = find_guid_and_validate_access(:read, guid, ServiceInstance)

Expand Down Expand Up @@ -597,4 +602,5 @@ def projected_service_instance(service_instance)
service_instance.clone.set(request_attrs.select { |k, _v| ServiceInstanceUpdate::KEYS_TO_UPDATE_CC.include? k })
end
end
# rubocop:enable Metrics/ClassLength
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,28 @@ def stub_delete_and_return(status, body)
end
end

describe 'GET', '/v2/managed_service_instances' do
let(:service_instance) { ManagedServiceInstance.make(gateway_name: Sham.name) }
let(:space) { service_instance.space }
let(:developer) { make_developer_for_space(space) }

it 'is deprecated' do
set_current_user(developer)
get '/v2/managed_service_instances'
expect(last_response).to be_a_deprecated_response
end

it 'behaves the same as /v2/service_instances/' do
set_current_user(developer)
get '/v2/managed_service_instances'
deprecated_response = last_response
expect(deprecated_response).to have_status_code(200)
get '/v2/service_instances'
new_response = last_response
expect(new_response.body).to eq(deprecated_response.body)
end
end

describe 'GET /v2/service_instances' do
context 'dashboard_url' do
let(:service_instance) { ManagedServiceInstance.make(gateway_name: Sham.name) }
Expand Down Expand Up @@ -1535,6 +1557,29 @@ def stub_delete_and_return(status, body)
end
end

describe 'GET', '/v2/managed_service_instances/:guid' do
let(:space) { Space.make }
let(:developer) { make_developer_for_space(space) }
let(:service_instance) { ManagedServiceInstance.make(space:) }
let(:service_plan) { ServicePlan.make(active: false) }

it 'is deprecated' do
set_current_user(developer)
get "v2/managed_service_instances/#{service_instance.guid}"
expect(last_response).to be_a_deprecated_response
end

it 'behaves the same as /v2/service_instances/:guid' do
set_current_user(developer)
get "v2/managed_service_instances/#{service_instance.guid}"
deprecated_response = last_response
expect(deprecated_response).to have_status_code(200)
get "v2/service_instances/#{service_instance.guid}"
new_response = last_response
expect(new_response.body).to eq(deprecated_response.body)
end
end

describe 'GET /v2/service_instances/:service_instance_guid' do
let(:space) { service_instance.space }
let(:developer) { make_developer_for_space(space) }
Expand Down

0 comments on commit 8e1672b

Please sign in to comment.