Add oslo_middleware/enable_proxy_headers_parsing option

Change-Id: I59ce740ad85967e181da328e11d394cc1c029ab6
This commit is contained in:
Jake Yip 2020-09-02 18:07:35 +10:00 committed by Jake Yip
parent f66eea46e2
commit e2b05c8956
3 changed files with 55 additions and 22 deletions

View File

@ -64,20 +64,26 @@
# (Optional) Number of API workers.
# Defaults to $::os_workers
#
# [*enable_proxy_headers_parsing*]
# (optional) This determines if the HTTPProxyToWSGI
# middleware should parse the proxy headers or not.(boolean value)
# Defaults to $::os_service_default
#
class magnum::api(
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$service_name = $::magnum::params::api_service,
$port = '9511',
$host = '127.0.0.1',
$max_limit = '1000',
$sync_db = true,
$auth_strategy = 'keystone',
$enabled_ssl = false,
$ssl_cert_file = $::os_service_default,
$ssl_key_file = $::os_service_default,
$workers = $::os_workers,
$package_ensure = 'present',
$enabled = true,
$manage_service = true,
$service_name = $::magnum::params::api_service,
$port = '9511',
$host = '127.0.0.1',
$max_limit = '1000',
$sync_db = true,
$auth_strategy = 'keystone',
$enabled_ssl = false,
$ssl_cert_file = $::os_service_default,
$ssl_key_file = $::os_service_default,
$workers = $::os_workers,
$enable_proxy_headers_parsing = $::os_service_default,
) inherits magnum::params {
include magnum::deps
@ -149,4 +155,9 @@ class magnum::api(
if $auth_strategy == 'keystone' {
include magnum::keystone::authtoken
}
oslo::middleware {'magnum_config':
enable_proxy_headers_parsing => $enable_proxy_headers_parsing,
}
}

View File

@ -0,0 +1,5 @@
---
features:
- |
Add support to configure the enable_proxy_headers_parsing parameter in the
oslo_middlware section.

View File

@ -10,15 +10,16 @@ describe 'magnum::api' do
end
let :default_params do
{ :package_ensure => 'present',
:enabled => true,
:port => '9511',
:host => '127.0.0.1',
:max_limit => '1000',
:sync_db => 'true',
:enabled_ssl => 'false',
:ssl_cert_file => '<SERVICE DEFAULT>',
:ssl_key_file => '<SERVICE DEFAULT>',
{ :package_ensure => 'present',
:enabled => true,
:port => '9511',
:host => '127.0.0.1',
:max_limit => '1000',
:sync_db => 'true',
:enabled_ssl => 'false',
:ssl_cert_file => '<SERVICE DEFAULT>',
:ssl_key_file => '<SERVICE DEFAULT>',
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
}
end
@ -60,6 +61,10 @@ describe 'magnum::api' do
is_expected.to contain_magnum_config('api/workers').with_value(facts[:os_workers])
end
it { is_expected.to contain_oslo__middleware('magnum_config').with(
:enable_proxy_headers_parsing => '<SERVICE DEFAULT>',
)}
context 'when overriding parameters' do
before :each do
params.merge!(
@ -91,6 +96,18 @@ describe 'magnum::api' do
it { is_expected.to contain_magnum_config('api/ssl_cert_file').with_value(p[:ssl_cert_file]) }
it { is_expected.to contain_magnum_config('api/ssl_key_file').with_value(p[:ssl_key_file]) }
end
context 'with oslo_middleware configured' do
let :params do
{
:enable_proxy_headers_parsing => true,
}
end
it { is_expected.to contain_oslo__middleware('magnum_config').with(
:enable_proxy_headers_parsing => 'true',
)}
end
end
shared_examples 'magnum-api wsgi' do