From cb6cf8d170f1faf559eb291130c1bfe221ff181f Mon Sep 17 00:00:00 2001 From: Matthew Haughton Date: Sat, 18 Jan 2014 13:31:05 -0500 Subject: [PATCH] test vhost name is sanitized --- spec/defines/resource_location_spec.rb | 12 ++++++++++++ spec/defines/resource_vhost_spec.rb | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 14610e2c3..82de85714 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -538,6 +538,18 @@ it { expect { should contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, /Cannot define both directory and proxy in a virtual host/) } end + + context 'when vhost name is sanitized' do + let :title do 'www.rspec-location.com' end + let :params do { + :vhost => 'www rspec-vhost com', + :www_root => '/', + :ssl => true, + } end + + it { should contain_concat__fragment("www_rspec-vhost_com-500-www.rspec-location.com").with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + it { should contain_concat__fragment("www_rspec-vhost_com-800-www.rspec-location.com-ssl").with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + end end end end diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index c980ba68e..573953dc8 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -600,6 +600,13 @@ it { should contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_cgi_param test2 test value 2;/ ) } it { should contain_concat__fragment("#{title}-ssl-header").with_content( /passenger_set_cgi_param test3 test value 3;/ ) } end + + context 'when vhost name is sanitized' do + let :title do 'www rspec-vhost com' end + let :params do default_params end + + it { should contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + end end end end