Skip to content

Commit bcac140

Browse files
committed
Keep /v2/info endpoint when v2 is disabled
1 parent f629077 commit bcac140

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

app/controllers/runtime/info_controller.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,25 @@ class InfoController < RestController::BaseController
44

55
get '/v2/info', :read
66
def read
7+
unless @config.get(:temporary_enable_v2)
8+
return Oj.dump({
9+
name: @config.get(:info, :name),
10+
build: @config.get(:info, :build),
11+
support: 'CF API v2 is disabled',
12+
version: @config.get(:info, :version),
13+
description: @config.get(:info, :description),
14+
authorization_endpoint: @config.get(:login, :url),
15+
token_endpoint: config.get(:uaa, :url),
16+
min_cli_version: @config.get(:info, :min_cli_version),
17+
min_recommended_cli_version: @config.get(:info, :min_recommended_cli_version),
18+
app_ssh_endpoint: @config.get(:info, :app_ssh_endpoint),
19+
app_ssh_host_key_fingerprint: @config.get(:info, :app_ssh_host_key_fingerprint),
20+
app_ssh_oauth_client: @config.get(:info, :app_ssh_oauth_client),
21+
doppler_logging_endpoint: @config.get(:doppler, :url),
22+
api_version: '',
23+
osbapi_version: VCAP::CloudController::Constants::OSBAPI_VERSION
24+
}, mode: :compat)
25+
end
726
info = {
827
name: @config.get(:info, :name),
928
build: @config.get(:info, :build),

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)