Add support for [cors] options
Change-Id: I8531ac8d7e360abf3bea079208c5fa0d9d2169a5
This commit is contained in:
parent
7cfa5fe93a
commit
168d1eb182
58
manifests/cors.pp
Normal file
58
manifests/cors.pp
Normal file
@ -0,0 +1,58 @@
|
||||
# == Class: placement::cors
|
||||
#
|
||||
# Configure the placement cors
|
||||
#
|
||||
# === Parameters
|
||||
#
|
||||
# [*allowed_origin*]
|
||||
# (Optional) Indicate whether this resource may be shared with the domain
|
||||
# received in the requests "origin" header.
|
||||
# (string value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*allow_credentials*]
|
||||
# (Optional) Indicate that the actual request can include user credentials.
|
||||
# (boolean value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*expose_headers*]
|
||||
# (Optional) Indicate which headers are safe to expose to the API.
|
||||
# (list value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*max_age*]
|
||||
# (Optional) Maximum cache age of CORS preflight requests.
|
||||
# (integer value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*allow_methods*]
|
||||
# (Optional) Indicate which methods can be used during the actual request.
|
||||
# (list value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
# [*allow_headers*]
|
||||
# (Optional) Indicate which header field names may be used during the actual
|
||||
# request.
|
||||
# (list value)
|
||||
# Defaults to $::os_service_default.
|
||||
#
|
||||
class placement::cors (
|
||||
$allowed_origin = $::os_service_default,
|
||||
$allow_credentials = $::os_service_default,
|
||||
$expose_headers = $::os_service_default,
|
||||
$max_age = $::os_service_default,
|
||||
$allow_methods = $::os_service_default,
|
||||
$allow_headers = $::os_service_default,
|
||||
) {
|
||||
|
||||
include placement::deps
|
||||
|
||||
oslo::cors { 'placement_config':
|
||||
allowed_origin => $allowed_origin,
|
||||
allow_credentials => $allow_credentials,
|
||||
expose_headers => $expose_headers,
|
||||
max_age => $max_age,
|
||||
allow_methods => $allow_methods,
|
||||
allow_headers => $allow_headers,
|
||||
}
|
||||
}
|
4
releasenotes/notes/cors-32d7aada2d1a6a11.yaml
Normal file
4
releasenotes/notes/cors-32d7aada2d1a6a11.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``placement::cors`` class has been added.
|
53
spec/classes/placement_cors_spec.rb
Normal file
53
spec/classes/placement_cors_spec.rb
Normal file
@ -0,0 +1,53 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'placement::cors' do
|
||||
|
||||
shared_examples_for 'placement::cors' do
|
||||
it 'configure cors default params' do
|
||||
is_expected.to contain_oslo__cors('placement_config').with(
|
||||
:allowed_origin => '<SERVICE DEFAULT>',
|
||||
:allow_credentials => '<SERVICE DEFAULT>',
|
||||
:expose_headers => '<SERVICE DEFAULT>',
|
||||
:max_age => '<SERVICE DEFAULT>',
|
||||
:allow_methods => '<SERVICE DEFAULT>',
|
||||
:allow_headers => '<SERVICE DEFAULT>',
|
||||
)
|
||||
end
|
||||
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :allowed_origin => '*',
|
||||
:allow_credentials => true,
|
||||
:expose_headers => 'Content-Language,Expires',
|
||||
:max_age => 3600,
|
||||
:allow_methods => 'GET,POST,PUT,DELETE,OPTIONS',
|
||||
:allow_headers => 'Content-Type,Cache-Control',
|
||||
}
|
||||
end
|
||||
|
||||
it 'configure cors params' do
|
||||
is_expected.to contain_oslo__cors('placement_config').with(
|
||||
:allowed_origin => '*',
|
||||
:allow_credentials => true,
|
||||
:expose_headers => 'Content-Language,Expires',
|
||||
:max_age => 3600,
|
||||
:allow_methods => 'GET,POST,PUT,DELETE,OPTIONS',
|
||||
:allow_headers => 'Content-Type,Cache-Control',
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
facts.merge!(OSDefaults.get_facts())
|
||||
end
|
||||
|
||||
it_behaves_like 'placement::cors'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user