diff --git a/spec/acceptance/init_spec.rb b/spec/acceptance/init_spec.rb index 7b39cdd..64ada1c 100644 --- a/spec/acceptance/init_spec.rb +++ b/spec/acceptance/init_spec.rb @@ -1,65 +1,81 @@ require 'spec_helper_acceptance' describe 'nginx class' do context 'default parameters' do # Using puppet_apply as a helper it 'works idempotently with no errors' do - pp = 'include nginx' + pp = " + include nginx + + nginx::resource::server { 'example.com': + ensure => present, + www_root => '/var/www/html', + } + " # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end # do some basic checks pkg = case fact('os.family') when 'Archlinux' 'nginx-mainline' else 'nginx' end describe package(pkg) do it { is_expected.to be_installed } end describe service('nginx') do it { is_expected.to be_running } it { is_expected.to be_enabled } end describe port(80) do it { is_expected.to be_listening } end end context 'with service_config_check true' do # Using puppet_apply as a helper it 'works idempotently with no errors' do - pp = "class { 'nginx': service_config_check => true, }" + pp = " + class { 'nginx': + service_config_check => true, + } + + nginx::resource::server { 'example.com': + ensure => present, + www_root => '/var/www/html', + } + " # Run it twice and test for idempotency apply_manifest(pp, catch_failures: true) apply_manifest(pp, catch_changes: true) end # do some basic checks pkg = case fact('os.family') when 'Archlinux' 'nginx-mainline' else 'nginx' end describe package(pkg) do it { is_expected.to be_installed } end describe service('nginx') do it { is_expected.to be_running } it { is_expected.to be_enabled } end describe port(80) do it { is_expected.to be_listening } end end end diff --git a/spec/acceptance/nginx_mail_spec.rb b/spec/acceptance/nginx_mail_spec.rb index 93b2070..cbca967 100644 --- a/spec/acceptance/nginx_mail_spec.rb +++ b/spec/acceptance/nginx_mail_spec.rb @@ -1,67 +1,87 @@ require 'spec_helper_acceptance' describe 'nginx::resource::mailhost define:' do it 'runs successfully' do pp = " + if fact('os.family') == 'RedHat' { + package { 'nginx-mod-mail': + ensure => installed, + } + } + class { 'nginx': - mail => true, + mail => true, + dynamic_modules => fact('os.family') ? { + 'RedHat' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'], + default => [], + } } nginx::resource::mailhost { 'domain1.example': ensure => present, auth_http => 'localhost/cgi-bin/auth', protocol => 'smtp', listen_port => 587, ssl => true, ssl_port => 465, ssl_cert => '/etc/pki/tls/certs/blah.cert', ssl_key => '/etc/pki/tls/private/blah.key', xclient => 'off', } " apply_manifest(pp, catch_failures: true) end describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do it { is_expected.to be_file } it { is_expected.to contain 'auth_http localhost/cgi-bin/auth;' } it { is_expected.to contain 'listen *:465 ssl;' } end describe port(587) do it { is_expected.to be_listening } end describe port(465) do it { is_expected.to be_listening } end context 'when configured for nginx 1.14' do it 'runs successfully' do pp = " + if fact('os.family') == 'RedHat' { + package { 'nginx-mod-mail': + ensure => installed, + } + } + class { 'nginx': - mail => true, - nginx_version => '1.14.0', + mail => true, + nginx_version => '1.14.0', + dynamic_modules => fact('os.family') ? { + 'RedHat' => ['/usr/lib64/nginx/modules/ngx_mail_module.so'], + default => [], + } } nginx::resource::mailhost { 'domain1.example': ensure => present, auth_http => 'localhost/cgi-bin/auth', protocol => 'smtp', listen_port => 587, ssl => true, ssl_port => 465, ssl_cert => '/etc/pki/tls/certs/blah.cert', ssl_key => '/etc/pki/tls/private/blah.key', xclient => 'off', } " apply_manifest(pp, catch_failures: true) end describe file('/etc/nginx/conf.mail.d/domain1.example.conf') do it 'does\'t contain `ssl` on `listen` line' do is_expected.to contain 'listen *:465;' end end end end