From 4da8f4949977bfbbed702bb4ab6a2fbed11a9ffb Mon Sep 17 00:00:00 2001 From: Farzad FARID Date: Fri, 10 Apr 2015 00:58:32 +0200 Subject: [PATCH] Fix test condition for proxy directives. The _proxy.erb partial template must also be inserted when only @proxy_dest_match or @proxy_dest_match are set. --- manifests/vhost.pp | 2 +- spec/defines/vhost_spec.rb | 24 ++++++++++++++++++++++++ templates/vhost/_proxy.erb | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/manifests/vhost.pp b/manifests/vhost.pp index 60b5124e1..976bd1f8b 100644 --- a/manifests/vhost.pp +++ b/manifests/vhost.pp @@ -628,7 +628,7 @@ # - $proxy_pass_match # - $proxy_preserve_host # - $no_proxy_uris - if $proxy_dest or $proxy_pass or $proxy_pass_match { + if $proxy_dest or $proxy_pass or $proxy_pass_match or $proxy_dest_match { concat::fragment { "${name}-proxy": target => "${priority_real}${filename}.conf", order => 140, diff --git a/spec/defines/vhost_spec.rb b/spec/defines/vhost_spec.rb index 489c9b43f..325a06333 100644 --- a/spec/defines/vhost_spec.rb +++ b/spec/defines/vhost_spec.rb @@ -414,6 +414,30 @@ it { is_expected.to contain_concat__fragment('rspec.example.com-charsets') } it { is_expected.to contain_concat__fragment('rspec.example.com-file_footer') } end + context 'proxy_pass_match' do + let :params do + { + 'docroot' => '/rspec/docroot', + 'proxy_pass_match' => [ + { + 'path' => '.*', + 'url' => 'http://backend-a/', + } + ], + } + end + it { is_expected.to contain_concat__fragment('rspec.example.com-proxy').with_content( + /ProxyPassMatch .* http:\/\/backend-a\//).with_content(/## Proxy rules/) } + end + context 'proxy_dest_match' do + let :params do + { + 'docroot' => '/rspec/docroot', + 'proxy_dest_match' => '/' + } + end + it { is_expected.to contain_concat__fragment('rspec.example.com-proxy').with_content(/## Proxy rules/) } + end context 'not everything can be set together...' do let :params do { diff --git a/templates/vhost/_proxy.erb b/templates/vhost/_proxy.erb index f290fcb76..157e2ef40 100644 --- a/templates/vhost/_proxy.erb +++ b/templates/vhost/_proxy.erb @@ -1,4 +1,4 @@ -<% if @proxy_dest or @proxy_pass -%> +<% if @proxy_dest or @proxy_pass or @proxy_pass_match or @proxy_dest_match -%> ## Proxy rules ProxyRequests Off