Browse Source

added tests

James R. Carr 9 years ago
parent
commit
6891c37864
2 changed files with 35 additions and 0 deletions
  1. 18 0
      spec/defines/resource_vhost_spec.rb
  2. 17 0
      tests/vhost_ssl.pp

+ 18 - 0
spec/defines/resource_vhost_spec.rb

@@ -812,6 +812,24 @@ describe 'nginx::resource::vhost' do
         it { is_expected.to contain_file("/etc/nginx/#{title}.key") }
       end
 
+      context 'when ssl_client_cert is set' do
+        let :params do default_params.merge({
+          :ssl                => true,
+          :listen_port        => 80,
+          :ssl_port           => 80,
+          :ssl_key            => 'dummy.key',
+          :ssl_cert           => 'dummy.cert',
+          :ssl_client_cert    => 'client.cert',
+        }) end
+
+        it { is_expected.to contain_nginx__resource__location("#{title}-default").with_ssl_only(true) }
+        it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{access_log\s+/var/log/nginx/ssl-www\.rspec\.example\.com\.access\.log combined;}) }
+        it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{error_log\s+/var/log/nginx/ssl-www\.rspec\.example\.com\.error\.log}) }
+        it { is_expected.to contain_concat__fragment("#{title}-ssl-header").with_content(%r{client_verify on;}) }
+        it { is_expected.to contain_file("/etc/nginx/#{title}.crt") }
+        it { is_expected.to contain_file("/etc/nginx/#{title}.client.crt") }
+        it { is_expected.to contain_file("/etc/nginx/#{title}.key") }
+      end
       context 'when passenger_cgi_param is set' do
         let :params do default_params.merge({
           :passenger_cgi_param => { 'test1' => 'test value 1', 'test2' => 'test value 2', 'test3' => 'test value 3' }

+ 17 - 0
tests/vhost_ssl.pp

@@ -1,5 +1,14 @@
 include nginx
 
+nginx::resource::vhost { 'test3.local test3':
+  ensure          => present,
+  www_root        => '/var/www/nginx-default',
+  ssl             => true,
+  ssl_cert        => 'puppet:///modules/sslkey/whildcard_mydomain.crt',
+  ssl_client_cert => 'puppet:///modules/sslkey/whildcard_mydomain.crt',
+  ssl_key         => 'puppet:///modules/sslkey/whildcard_mydomain.key'
+}
+
 nginx::resource::vhost { 'test2.local test2':
   ensure   => present,
   www_root => '/var/www/nginx-default',
@@ -15,3 +24,11 @@ nginx::resource::location { 'test2.local-bob':
   vhost    => 'test2.local test2',
 }
 
+nginx::resource::location { 'test3.local-bob':
+  ensure   => present,
+  www_root => '/var/www/bob',
+  location => '/bob',
+  vhost    => 'test3.local test3',
+}
+
+