diff --git a/manifests/proxy/formpost.pp b/manifests/proxy/formpost.pp index 0943658a..d26575c2 100644 --- a/manifests/proxy/formpost.pp +++ b/manifests/proxy/formpost.pp @@ -1,6 +1,12 @@ # # Configure swift formpost. # +# == Parameters +# +# [*allowed_digests*] +# The digest algorithm(s) supported for generating signatures. +# Optional. Defaults to $facts['os_service_default']. +# # == Dependencies # # == Examples @@ -15,11 +21,14 @@ # # Copyright 2012 eNovance licensing@enovance.com # -class swift::proxy::formpost() { +class swift::proxy::formpost( + $allowed_digests = $facts['os_service_default'], +) { include swift::deps swift_proxy_config { - 'filter:formpost/use': value => 'egg:swift#formpost'; + 'filter:formpost/use': value => 'egg:swift#formpost'; + 'filter:formpost/allowed_digests': value => join(any2array($allowed_digests), ' '); } } diff --git a/manifests/proxy/tempurl.pp b/manifests/proxy/tempurl.pp index 092b27b2..ee77b802 100644 --- a/manifests/proxy/tempurl.pp +++ b/manifests/proxy/tempurl.pp @@ -28,6 +28,10 @@ # Example: ['x-object-meta-public-*'] or 'x-object-meta-public-*' # Optional. Defaults to $facts['os_service_default']. # +# [*allowed_digests*] +# The digest algorithm(s) supported for generating signatures. +# Optional. Defaults to $facts['os_service_default']. +# # == Examples # # class {'swift::proxy::tempurl': @@ -50,22 +54,18 @@ class swift::proxy::tempurl ( $incoming_allow_headers = $facts['os_service_default'], $outgoing_remove_headers = $facts['os_service_default'], $outgoing_allow_headers = $facts['os_service_default'], + $allowed_digests = $facts['os_service_default'], ) { include swift::deps - $methods_real = join(any2array($methods), ' ') - $incoming_remove_headers_real = join(any2array($incoming_remove_headers), ' ') - $incoming_allow_headers_real = join(any2array($incoming_allow_headers), ' ') - $outgoing_remove_headers_real = join(any2array($outgoing_remove_headers), ' ') - $outgoing_allow_headers_real = join(any2array($outgoing_allow_headers), ' ') - swift_proxy_config { 'filter:tempurl/use': value => 'egg:swift#tempurl'; - 'filter:tempurl/methods': value => $methods_real; - 'filter:tempurl/incoming_remove_headers': value => $incoming_remove_headers_real; - 'filter:tempurl/incoming_allow_headers': value => $incoming_allow_headers_real; - 'filter:tempurl/outgoing_remove_headers': value => $outgoing_remove_headers_real; - 'filter:tempurl/outgoing_allow_headers': value => $outgoing_allow_headers_real; + 'filter:tempurl/methods': value => join(any2array($methods), ' '); + 'filter:tempurl/incoming_remove_headers': value => join(any2array($incoming_remove_headers), ' '); + 'filter:tempurl/incoming_allow_headers': value => join(any2array($incoming_allow_headers), ' '); + 'filter:tempurl/outgoing_remove_headers': value => join(any2array($outgoing_remove_headers), ' '); + 'filter:tempurl/outgoing_allow_headers': value => join(any2array($outgoing_allow_headers), ' '); + 'filter:tempurl/allowed_digests': value => join(any2array($allowed_digests), ' '); } } diff --git a/releasenotes/notes/allowed_digests-1b12b2f0483c4c68.yaml b/releasenotes/notes/allowed_digests-1b12b2f0483c4c68.yaml new file mode 100644 index 00000000..eb86e116 --- /dev/null +++ b/releasenotes/notes/allowed_digests-1b12b2f0483c4c68.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + The following classes now support the new ``allowed_digests`` parameter. + + - ``swift::proxy::formpost`` + - ``swift::proxy::tempurl`` diff --git a/spec/classes/swift_proxy_formpost_spec.rb b/spec/classes/swift_proxy_formpost_spec.rb index c6f4e30a..c7f4e366 100644 --- a/spec/classes/swift_proxy_formpost_spec.rb +++ b/spec/classes/swift_proxy_formpost_spec.rb @@ -2,7 +2,20 @@ require 'spec_helper' describe 'swift::proxy::formpost' do shared_examples 'swift::proxy::formpost' do - it { should contain_swift_proxy_config('filter:formpost/use').with_value('egg:swift#formpost') } + context 'with defaults' do + it { should contain_swift_proxy_config('filter:formpost/use').with_value('egg:swift#formpost') } + it { should contain_swift_proxy_config('filter:formpost/allowed_digests').with_value('') } + end + + context 'with parameters' do + let :params do + { + :allowed_digests => ['sha1', 'sha256', 'sha512'] + } + end + + it { should contain_swift_proxy_config('filter:formpost/allowed_digests').with_value('sha1 sha256 sha512') } + end end on_supported_os({ diff --git a/spec/classes/swift_proxy_tempurl_spec.rb b/spec/classes/swift_proxy_tempurl_spec.rb index 19fdf53b..cc158fb4 100644 --- a/spec/classes/swift_proxy_tempurl_spec.rb +++ b/spec/classes/swift_proxy_tempurl_spec.rb @@ -2,51 +2,69 @@ require 'spec_helper' describe 'swift::proxy::tempurl' do shared_examples 'swift::proxy::tempurl' do - it { is_expected.to contain_swift_proxy_config('filter:tempurl/use').with_value('egg:swift#tempurl') } - ['methods', - 'incoming_remove_headers', - 'incoming_allow_headers', - 'outgoing_remove_headers', - 'outgoing_allow_headers' ].each do |h| - it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('') } - end + context 'with defaults' do + it { is_expected.to contain_swift_proxy_config('filter:tempurl/use').with_value('egg:swift#tempurl') } - context "when params are set" do - let :params do { - 'methods' => ['GET','HEAD','PUT'], - 'incoming_remove_headers' => ['x-foo','x-bar-*'], - 'incoming_allow_headers' => ['x-foo','x-bar-*'], - 'outgoing_remove_headers' => ['x-foo','x-bar-*'], - 'outgoing_allow_headers' => ['x-foo','x-bar-*'], - } end - - it { is_expected.to contain_swift_proxy_config('filter:tempurl/methods').with_value('GET HEAD PUT') } - ['incoming_remove_headers', + [ + 'methods', + 'incoming_remove_headers', 'incoming_allow_headers', 'outgoing_remove_headers', - 'outgoing_allow_headers' ].each do |h| - it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('x-foo x-bar-*') } - end + 'outgoing_allow_headers', + 'allowed_digests' + ].each do |h| + it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('') } + end + end - describe 'when params are not array' do - let :params do { - 'methods' => 'GET HEAD PUT', - 'incoming_remove_headers' => 'x-foo x-bar-*', - 'incoming_allow_headers' => 'x-foo x-bar-*', - 'outgoing_remove_headers' => 'x-foo x-bar-*', - 'outgoing_allow_headers' => 'x-foo x-bar-*', - } end + context 'when params are set' do + let :params do + { + :methods => ['GET','HEAD','PUT'], + :incoming_remove_headers => ['x-foo','x-bar-*'], + :incoming_allow_headers => ['x-foo','x-bar-*'], + :outgoing_remove_headers => ['x-foo','x-bar-*'], + :outgoing_allow_headers => ['x-foo','x-bar-*'], + :allowed_digests => ['sha1', 'sha256', 'sha512'], + } + end - it { is_expected.to contain_swift_proxy_config('filter:tempurl/methods').with_value('GET HEAD PUT') } - ['incoming_remove_headers', - 'incoming_allow_headers', - 'outgoing_remove_headers', - 'outgoing_allow_headers' ].each do |h| - it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('x-foo x-bar-*') } - end - end - end + it { is_expected.to contain_swift_proxy_config('filter:tempurl/methods').with_value('GET HEAD PUT') } + [ + 'incoming_remove_headers', + 'incoming_allow_headers', + 'outgoing_remove_headers', + 'outgoing_allow_headers' + ].each do |h| + it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('x-foo x-bar-*') } + end + it { is_expected.to contain_swift_proxy_config('filter:tempurl/allowed_digests').with_value('sha1 sha256 sha512') } + end + + context 'when params are not array' do + let :params do + { + :methods => 'GET HEAD PUT', + :incoming_remove_headers => 'x-foo x-bar-*', + :incoming_allow_headers => 'x-foo x-bar-*', + :outgoing_remove_headers => 'x-foo x-bar-*', + :outgoing_allow_headers => 'x-foo x-bar-*', + :allowed_digests => 'sha1 sha256 sha512', + } + end + + it { is_expected.to contain_swift_proxy_config('filter:tempurl/methods').with_value('GET HEAD PUT') } + [ + 'incoming_remove_headers', + 'incoming_allow_headers', + 'outgoing_remove_headers', + 'outgoing_allow_headers', + ].each do |h| + it { is_expected.to contain_swift_proxy_config("filter:tempurl/#{h}").with_value('x-foo x-bar-*') } + end + it { is_expected.to contain_swift_proxy_config('filter:tempurl/allowed_digests').with_value('sha1 sha256 sha512') } + end end on_supported_os({