Skip to content

Commit

Permalink
Disable /v2/info endpoint if temporary_enable_v2 == false (#480)
Browse files Browse the repository at this point in the history
* Disable /v2/info endpoint if temporary_enable_v2 == false

* and also pass the parameter to the cloud_controller_ng.yml

* Add spec for new cloud_controller_ng property
  • Loading branch information
jochenehret authored Oct 23, 2024
1 parent 44b07cf commit 9b424c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ rate_limiter_v2_api:
per_process_admin_limit: <%= (p("cc.rate_limiter_v2_api.admin_limit").to_f/instances).ceil %>
reset_interval_in_minutes: <%= p("cc.rate_limiter_v2_api.reset_interval_in_minutes") %>

temporary_enable_v2: <%= p("cc.temporary_enable_v2") %>
<% unless p("cc.temporary_enable_deprecated_thin_webserver") && !p("cc.experimental.use_redis") %>
redis:
socket: "/var/vcap/data/valkey/valkey.sock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ location / {
}

<% if !p("cc.temporary_enable_v2") %>
location ~ /v2(?!/info) {
location ~ /v2/ {
return 404 "V2 endpoints disabled";
}
<% end %>
Expand Down
21 changes: 20 additions & 1 deletion spec/cloud_controller_ng/cloud_controller_ng_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ module Test
[{ 'description' => 'Cloud Foundry Linux-based filesystem',
'name' => 'cflinuxfs4' }],
'staging_upload_password' => '((cc_staging_upload_password))',
'staging_upload_user' => 'staging_user' },
'staging_upload_user' => 'staging_user',
'temporary_enable_v2' => true },
'ccdb' =>
{ 'databases' => [{ 'name' => 'cloud_controller', 'tag' => 'cc' }],
'db_scheme' => 'mysql',
Expand Down Expand Up @@ -501,6 +502,24 @@ module Test
end
end

describe 'enable v2 API' do
it 'is by default true' do
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['temporary_enable_v2']).to be(true)
end

context 'when explicitly disabled' do
before do
merged_manifest_properties['cc']['temporary_enable_v2'] = false
end

it 'is false' do
template_hash = YAML.safe_load(template.render(merged_manifest_properties, consumes: links))
expect(template_hash['temporary_enable_v2']).to be(false)
end
end
end

context 'when db connection expiration configuration is present' do
before do
merged_manifest_properties['ccdb']['connection_expiration_timeout'] = 3600
Expand Down

0 comments on commit 9b424c9

Please sign in to comment.