Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor refactor of v2 endpoints #4140

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading