Merge "Cors: Accept array for ListOpts"
This commit is contained in:
commit
71e3c3d5e8
@ -49,12 +49,12 @@ define oslo::cors(
|
||||
) {
|
||||
|
||||
$cors_options = {
|
||||
'cors/allowed_origin' => { value => $allowed_origin },
|
||||
'cors/allowed_origin' => { value => join(any2array($allowed_origin), ',') },
|
||||
'cors/allow_credentials' => { value => $allow_credentials },
|
||||
'cors/expose_headers' => { value => $expose_headers },
|
||||
'cors/expose_headers' => { value => join(any2array($expose_headers), ',') },
|
||||
'cors/max_age' => { value => $max_age },
|
||||
'cors/allow_methods' => { value => $allow_methods },
|
||||
'cors/allow_headers' => { value => $allow_headers }
|
||||
'cors/allow_methods' => { value => join(any2array($allow_methods), ',') },
|
||||
'cors/allow_headers' => { value => join(any2array($allow_headers), ',') }
|
||||
}
|
||||
create_resources($name, $cors_options)
|
||||
}
|
||||
|
@ -15,7 +15,46 @@ describe 'oslo::cors' do
|
||||
is_expected.to contain_keystone_config('cors/allow_methods').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_keystone_config('cors/allow_headers').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with parameters' do
|
||||
let (:params) do
|
||||
{
|
||||
:allowed_origin => 'https://horizon.example.com,https://horizon.example2.com',
|
||||
:allow_credentials => true,
|
||||
:expose_headers => 'HeaderOne,HeaderTwo',
|
||||
:max_age => 3600,
|
||||
:allow_methods => 'GET,HEAD',
|
||||
:allow_headers => 'HeaderThree,HeaderFour',
|
||||
}
|
||||
end
|
||||
|
||||
it 'configure cors params' do
|
||||
is_expected.to contain_keystone_config('cors/allowed_origin').with_value('https://horizon.example.com,https://horizon.example2.com')
|
||||
is_expected.to contain_keystone_config('cors/allow_credentials').with_value(true)
|
||||
is_expected.to contain_keystone_config('cors/expose_headers').with_value('HeaderOne,HeaderTwo')
|
||||
is_expected.to contain_keystone_config('cors/max_age').with_value(3600)
|
||||
is_expected.to contain_keystone_config('cors/allow_methods').with_value('GET,HEAD')
|
||||
is_expected.to contain_keystone_config('cors/allow_headers').with_value('HeaderThree,HeaderFour')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with parameters in array' do
|
||||
let (:params) do
|
||||
{
|
||||
:allowed_origin => ['https://horizon.example.com', 'https://horizon.example2.com'],
|
||||
:expose_headers => ['HeaderOne', 'HeaderTwo'],
|
||||
:allow_methods => ['GET', 'HEAD'],
|
||||
:allow_headers => ['HeaderThree', 'HeaderFour'],
|
||||
}
|
||||
end
|
||||
|
||||
it 'configure cors params' do
|
||||
is_expected.to contain_keystone_config('cors/allowed_origin').with_value('https://horizon.example.com,https://horizon.example2.com')
|
||||
is_expected.to contain_keystone_config('cors/expose_headers').with_value('HeaderOne,HeaderTwo')
|
||||
is_expected.to contain_keystone_config('cors/allow_methods').with_value('GET,HEAD')
|
||||
is_expected.to contain_keystone_config('cors/allow_headers').with_value('HeaderThree,HeaderFour')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user