From 72ee2a9dd0696f77c8f6375cb20ed39b7937109e Mon Sep 17 00:00:00 2001 From: Senthil Natarajan Date: Tue, 22 Oct 2019 12:06:55 -0500 Subject: [PATCH 1/2] Changes to support url encoded header in repose 9 --- ModuleFile | 2 +- manifests/filter/system_model.pp | 1 + puppet-module-repose.spec | 4 ++- spec/defines/filter/system_model_spec.rb | 38 ++++++++++++++++++++++++ templates/system-model.cfg.xml.erb | 2 +- 5 files changed, 44 insertions(+), 3 deletions(-) diff --git a/ModuleFile b/ModuleFile index 623a1da..eceefd0 100644 --- a/ModuleFile +++ b/ModuleFile @@ -1,5 +1,5 @@ name 'citops-repose' -version '2.11.0' +version '2.12.0' description "Repose is an api middleware that provides authentication, filtering, ratelimitting and several other features, this deploys it." project_page 'https://github.com/rackerlabs/puppet-repose' diff --git a/manifests/filter/system_model.pp b/manifests/filter/system_model.pp index f0192ff..dfcc40a 100644 --- a/manifests/filter/system_model.pp +++ b/manifests/filter/system_model.pp @@ -137,6 +137,7 @@ $rewrite_host_header = undef, $service_cluster = undef, $tracing_header = {}, + $encoded_headers = [], ) { ### Validate parameters diff --git a/puppet-module-repose.spec b/puppet-module-repose.spec index f7b1489..f2852e3 100644 --- a/puppet-module-repose.spec +++ b/puppet-module-repose.spec @@ -2,7 +2,7 @@ %define base_name repose Name: puppet-module-%{user}-%{base_name} -Version: 2.11.0 +Version: 2.12.0 Release: 1 BuildArch: noarch Summary: Puppet module to configure %{base_name} @@ -30,6 +30,8 @@ cp -pr * %{buildroot}%{module_dir}/ %{module_dir} %changelog +* Tue Oct 22 2019 Senthil Natarajan 2.12.0-1 +- Added support for url encoded header * Thu Aug 21 2019 Josh Bell 2.11.0-1 - Add basic support for Repose 9 in system model and other filters - Add support for installing identity filter bundle diff --git a/spec/defines/filter/system_model_spec.rb b/spec/defines/filter/system_model_spec.rb index f577a9c..24d0fdf 100644 --- a/spec/defines/filter/system_model_spec.rb +++ b/spec/defines/filter/system_model_spec.rb @@ -356,5 +356,43 @@ without_content(/services/) } end + + context 'defaults plus setting repose9 param with encoded headers' do + let :pre_condition do + "class { 'repose': cfg_new_namespace => true }" + end + + let(:title) { 'default' } + let(:params) { { + :ensure => 'present', + :repose9 => 'true', + :filename => 'system-model.cfg.xml', + :app_name => 'repose', + :nodes => ['app1', 'app2' ], + :filters => { + 10 => { 'name' => 'ip-identity' }, + }, + :endpoints => [ + { + 'id' => 'localhost', + 'protocol' => 'http', + 'hostname' => 'localhost', + 'root-path' => '', + 'port' => '80', + 'default' => 'true' + }, + ], + :encoded_headers => ['x-user-name', 'x-rax-roles'], + + } } + it { + should contain_file('/etc/repose/system-model.cfg.xml'). + without_content(/tracing-header/). + without_content(/rewrite-host-header/). + without_content(/repose-cluster/). + without_content(/services/). + with_content(/url-encode-headers="x-user-name,x-rax-roles"/) + } + end end end diff --git a/templates/system-model.cfg.xml.erb b/templates/system-model.cfg.xml.erb index ea90cf7..e4deba4 100644 --- a/templates/system-model.cfg.xml.erb +++ b/templates/system-model.cfg.xml.erb @@ -27,7 +27,7 @@ <%- end -%> <%- end -%> - + url-encode-headers="<%= @encoded_headers.join(",")%>" <%- end -%> > <%- @endpoints.each do |endpoint| -%> <%= param %>="<%= value %>" <% end %>/> <%- end -%> From e9354281f260e5b79090892d997d5bf2f8100b93 Mon Sep 17 00:00:00 2001 From: Senthil Natarajan Date: Wed, 23 Oct 2019 10:07:44 -0500 Subject: [PATCH 2/2] Documented the new attribute and fixed the style --- manifests/filter/system_model.pp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifests/filter/system_model.pp b/manifests/filter/system_model.pp index dfcc40a..f6c90e3 100644 --- a/manifests/filter/system_model.pp +++ b/manifests/filter/system_model.pp @@ -82,6 +82,9 @@ # system-model config. # Defaults to false False # +# [*encoded_headers*] +# Array of header names that need to be encoded before being sent to the origin service. +# # === Examples # # $app_name = 'repose' @@ -137,7 +140,7 @@ $rewrite_host_header = undef, $service_cluster = undef, $tracing_header = {}, - $encoded_headers = [], + $encoded_headers = [], ) { ### Validate parameters