fix spacing issues in various templates

Before this change, vhost_ssl_header would merge
"ssl" with any listen options, e.g.:
    listen       *:443 ssldefault;
when listen_options => 'default'.
This commit is contained in:
Matthew Haughton 2013-11-21 23:04:39 -05:00
parent c8d9ad5680
commit 4af2087867
10 changed files with 50 additions and 40 deletions

View file

@ -121,34 +121,32 @@ describe 'nginx::resource::location' do
:value => 'my_location',
:match => ' location my_location {',
},
# TODO: fix in template so following matches
#{
# :title => 'should contain ordered prepended directives',
# :attr => 'location_cfg_prepend',
# :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
# :match => [
# ' allow test value 3;',
# ' test1 test value 1;',
# ' test2 test value 2;',
# ],
#},
{
:title => 'should contain ordered prepended directives',
:attr => 'location_cfg_prepend',
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
:match => [
' allow test value 3;',
' test1 test value 1;',
' test2 test value 2;',
],
},
{
:title => 'should set alias',
:attr => 'location_alias',
:value => 'value',
:match => ' alias value;',
},
#TODO: fix in template so following matches
#{
# :title => 'should contain ordered appended directives',
# :attr => 'location_cfg_append',
# :value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
# :match => [
# ' allow test value 3; ',
# ' test1 test value 1; ',
# ' test2 test value 2; ',
# ],
#},
{
:title => 'should contain ordered appended directives',
:attr => 'location_cfg_append',
:value => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' },
:match => [
' allow test value 3;',
' test1 test value 1;',
' test2 test value 2;',
],
},
].each do |param|
context "when #{param[:attr]} is #{param[:value]}" do
let :default_params do { :location => 'location', :location_alias => 'location_alias_value', :vhost => 'vhost1' } end
@ -247,7 +245,7 @@ describe 'nginx::resource::location' do
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2 ;', #TODO
:match => ' try_files name1 name2;',
},
{
:title => 'should set fastcgi_params',
@ -332,7 +330,7 @@ describe 'nginx::resource::location' do
:title => 'should set try_file(s)',
:attr => 'try_files',
:value => ['name1','name2'],
:match => ' try_files name1 name2 ;', #TODO
:match => ' try_files name1 name2;',
},
{
:title => 'should set index_file(s)',

View file

@ -39,13 +39,13 @@ describe 'nginx::resource::mailhost' do
:title => 'should set the IPv4 listen IP',
:attr => 'listen_ip',
:value => '127.0.0.1',
:match => ' listen 127.0.0.1:25 ;', #TODO
:match => ' listen 127.0.0.1:25;',
},
{
:title => 'should set the IPv4 listen port',
:attr => 'listen_port',
:value => '45',
:match => ' listen *:45 ;', #TODO
:match => ' listen *:45;',
},
{
:title => 'should set the IPv4 listen options',
@ -83,6 +83,12 @@ describe 'nginx::resource::mailhost' do
:value => 'spdy',
:match => ' listen [::]:80 spdy ipv6only=on;',
},
{
:title => 'should not set the IPv6 listen options',
:attr => 'ipv6_listen_options',
:value => false,
:match => ' listen [::]:80 ipv6only=on;',
},
{
:title => 'should set servername(s)',
:attr => 'server_name',

View file

@ -40,9 +40,7 @@ describe 'nginx::resource::upstream' do
:match => [
' test1 test value 1;',
' test2 test value 2;',
#TODO: fix this output in the template; should be no trailing
#spaces
' test3 test value 3; ',
' test3 test value 3;',
],
},
{

View file

@ -284,8 +284,13 @@ describe 'nginx::resource::vhost' do
:title => 'should set the IPv4 listen options',
:attr => 'listen_options',
:value => 'default',
#TODO: fix me in template
:match => ' listen *:443 ssldefault;',
:match => ' listen *:443 ssl default;',
},
{
:title => 'should not set the IPv4 listen options',
:attr => 'listen_options',
:value => false,
:match => ' listen *:443 ssl;',
},
# {
# :title => 'should enable IPv6',

View file

@ -1,6 +1,7 @@
upstream <%= @name %> {
<% if @upstream_cfg_prepend -%><% upstream_cfg_prepend.sort_by{|k,v| k}.each do |key,value| %>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
<% @members.each do |i| %>
server <%= i %>;<% end %>
}

View file

@ -1,9 +1,9 @@
server {
listen <%= listen_ip %>:<%= listen_port %> <% if @listen_options %><%= listen_options %><% end %>;
listen <%= listen_ip %>:<%= listen_port %><% if @listen_options %> <%= listen_options %><% end %>;
<% # check to see if ipv6 support exists in the kernel before applying %>
<% if ipv6_enable && (defined? @ipaddress6) %>
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %> <% if @ipv6_listen_options %><%= ipv6_listen_options %><% end %> ipv6only=on;
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %><% if @ipv6_listen_options %> <%= ipv6_listen_options %><% end %> ipv6only=on;
<% end %>
server_name <%= server_name.join(" ") %>;
protocol <%= protocol %>;

View file

@ -1,8 +1,10 @@
location <%= @location %> {
<% if @location_cfg_prepend -%><% @location_cfg_prepend.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
alias <%= @location_alias %>;
<% if @location_cfg_append -%><% @location_cfg_append.sort_by {|k,v| k}.each do |key,value| -%>
<%= key %> <%= value %>;<% end -%><% end -%>
<%= key %> <%= value %>;
<% end -%><% end -%>
}

View file

@ -12,7 +12,7 @@
root <%= @www_root %>;
<% end -%>
<% if @try_files -%>
try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>;
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>
<% if @index_files -%>
index <% @index_files.each do |i| %> <%= i %><% end %>;

View file

@ -9,7 +9,7 @@
fastcgi_split_path_info <%= @fastcgi_split_path %>;
<% end -%>
<% if @try_files -%>
try_files <% @try_files.each do |try| -%> <%= try %> <% end -%>;
try_files<% @try_files.each do |try| -%> <%= try %><% end -%>;
<% end -%>
include <%= @fastcgi_params %>;
fastcgi_pass <%= @fastcgi %>;

View file

@ -1,7 +1,7 @@
server {
listen <%= @listen_ip %>:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @listen_options %><%= @listen_options %><% end %>;
listen <%= @listen_ip %>:<%= @ssl_port %> ssl<% if @spdy == 'on' %> spdy<% end %><% if @listen_options %> <%= @listen_options %><% end %>;
<% if @ipv6_enable == 'true' && (defined? @ipaddress6) %>
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %> <% if @ipv6_listen_options %><%= @ipv6_listen_options %><% end %> ipv6only=on;
listen [<%= @ipv6_listen_ip %>]:<%= @ipv6_listen_port %><% if @ipv6_listen_options %> <%= @ipv6_listen_options %><% end %> ipv6only=on;
<% end %>
server_name <%= @rewrite_www_to_non_www ? @name.gsub(/^www\./, '') : @server_name.join(" ") %>;