Skip to content

Commit 04c46ec

Browse files
authored
Keep /v2/info endpoint when v2 is disabled (#4280)
* Keep /v2/info endpoint when v2 is disabled
1 parent 81e3e18 commit 04c46ec

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

app/controllers/runtime/info_controller.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def read
2828

2929
info[:user] = user.guid if user
3030

31+
unless @config.get(:temporary_enable_v2)
32+
info[:support] = 'CF API v2 is disabled'
33+
info[:api_version] = ''
34+
end
35+
3136
Oj.dump(info, mode: :compat)
3237
end
3338
end

spec/unit/controllers/runtime/info_controller_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ module VCAP::CloudController
6161
expect(hash['min_recommended_cli_version']).to eq('min_recommended_cli_version')
6262
end
6363

64+
it 'returns limited info when cc.temporary_enable_v2 is disabled' do
65+
TestConfig.override(temporary_enable_v2: false)
66+
67+
get '/v2/info'
68+
hash = Oj.load(last_response.body)
69+
expect(hash['name']).to eq(TestConfig.config[:info][:name])
70+
expect(hash['build']).to eq(TestConfig.config[:info][:build])
71+
expect(hash['support']).to eq('CF API v2 is disabled')
72+
expect(hash['version']).to eq(TestConfig.config[:info][:version])
73+
expect(hash['description']).to eq(TestConfig.config[:info][:description])
74+
expect(hash['authorization_endpoint']).to eq(TestConfig.config[:login][:url])
75+
expect(hash['token_endpoint']).to eq(TestConfig.config[:uaa][:url])
76+
expect(hash['app_ssh_endpoint']).to eq(TestConfig.config[:info][:app_ssh_endpoint])
77+
expect(hash['app_ssh_host_key_fingerprint']).to eq(TestConfig.config[:info][:app_ssh_host_key_fingerprint])
78+
expect(hash['app_ssh_oauth_client']).to eq(TestConfig.config[:info][:app_ssh_oauth_client])
79+
expect(hash['api_version']).to eq('')
80+
expect(hash['osbapi_version']).to eq(VCAP::CloudController::Constants::OSBAPI_VERSION)
81+
end
82+
6483
describe 'custom fields' do
6584
context 'without custom fields in config' do
6685
before { TestConfig.override(info: {}) }

0 commit comments

Comments
 (0)