From d90932738019ea02d54d60e28cd271855ae44471 Mon Sep 17 00:00:00 2001 From: Stefan Baryakov Date: Fri, 23 Jan 2015 14:33:49 +0100 Subject: [PATCH 1/2] sort add_header values for vhost --- spec/defines/resource_vhost_spec.rb | 15 +++++++++++++++ templates/vhost/vhost_header.erb | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index f8c6616..c9eccff 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -847,6 +847,21 @@ describe 'nginx::resource::vhost' do it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } end + + context 'when add_hedar is set' do + let :params do default_params.merge({ + :add_header => { 'header3' => 'test value 3', 'header2' => 'test value 2', 'header1' => 'test value 1' } + }) end + + it 'should have correctly ordered entries in the config' do + is_expected.to contain_concat__fragment("#{title}-header").with_content(/ + %r| + \s+add_header\s+header1 test value 1;\n + \s+add_header\s+header2 test value 2;\n + \s+add_header\s+header3 test value 3;\n + |/) + end + end end end end diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index ce343a2..70c2115 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -70,8 +70,8 @@ server { resolver <% Array(@resolver).each do |r| %> <%= r %><% end %>; <% end -%> <% if @add_header -%> - <%- @add_header.each do |key,value| -%> - add_header <%= key %> <%= value %>; + <%- @add_header.keys.sort.each do |key| -%> + add_header <%= key %> <%= @add_header[key] %>; <%- end -%> <% end -%> <% if @rewrite_to_https -%> From 5213d950f7bd3642e1dabefcbc6576c85d831d97 Mon Sep 17 00:00:00 2001 From: Stefan Baryakov Date: Mon, 26 Jan 2015 09:36:31 +0100 Subject: [PATCH 2/2] fix misspelling --- spec/defines/resource_vhost_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index c9eccff..c4a6eb6 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -848,7 +848,7 @@ describe 'nginx::resource::vhost' do it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } end - context 'when add_hedar is set' do + context 'when add_header is set' do let :params do default_params.merge({ :add_header => { 'header3' => 'test value 3', 'header2' => 'test value 2', 'header1' => 'test value 1' } }) end