From c9613ac6702f0ac805a2f310207a24e23b92e228 Mon Sep 17 00:00:00 2001 From: Stanislav Voroniy Date: Fri, 11 Sep 2015 14:37:33 +0200 Subject: [PATCH] Fixes for Travis CI --- Berksfile | 4 +-- Gemfile | 2 +- attributes/default.rb | 3 +- recipes/_common.rb | 4 +-- recipes/aliases.rb | 2 +- recipes/default.rb | 29 +++++-------------- recipes/relay_restrictions.rb | 1 - spec/wrapper_spec.rb | 1 + .../cookbooks/wrapper/attributes/default.rb | 14 +++++---- test/fixtures/cookbooks/wrapper/metadata.rb | 1 + .../cookbooks/wrapper/recipes/default.rb | 2 +- .../helpers/serverspec/spec_helper.rb | 17 +++++------ 12 files changed, 33 insertions(+), 47 deletions(-) diff --git a/Berksfile b/Berksfile index 3d60e57..71d3d18 100644 --- a/Berksfile +++ b/Berksfile @@ -5,6 +5,6 @@ metadata group :integration do cookbook 'apt' cookbook 'yum' - cookbook 'fake', :path => 'test/fixtures/cookbooks/fake' - cookbook 'wrapper', :path => 'test/fixtures/cookbooks/wrapper' + cookbook 'fake', path: 'test/fixtures/cookbooks/fake' + cookbook 'wrapper', path: 'test/fixtures/cookbooks/wrapper' end diff --git a/Gemfile b/Gemfile index 46455bc..9fdfd97 100644 --- a/Gemfile +++ b/Gemfile @@ -36,4 +36,4 @@ group :development do gem 'rake' gem 'fauxhai' gem 'pry-nav' -end \ No newline at end of file +end diff --git a/attributes/default.rb b/attributes/default.rb index f14a4cf..d3b857b 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -16,7 +16,7 @@ # limitations under the License. # Generic cookbook attributes -default['postfix']['mail_type'] = 'client' +default['postfix']['mail_type'] = 'client' default['postfix']['relayhost_role'] = 'relayhost' default['postfix']['multi_environment_relay'] = false default['postfix']['use_procmail'] = false @@ -145,4 +145,3 @@ end if node['postfix']['use_relay_restirictions_maps'] default['postfix']['main']['smtpd_relay_restrictions'] = "hash:#{node['postfix']['relay_restrictions_db']}, reject" end - diff --git a/recipes/_common.rb b/recipes/_common.rb index b8fc106..4d764c6 100644 --- a/recipes/_common.rb +++ b/recipes/_common.rb @@ -57,7 +57,7 @@ when 'omnios' # we don't guard this because if the user creation was successful (or happened out of band), then this won't get executed when the action is :nothing. execute '/opt/omni/sbin/postfix set-permissions' - template manifest_path do + template manifest_path do source 'manifest-postfix.xml.erb' owner 'root' group node['root_group'] @@ -100,7 +100,7 @@ unless node['postfix']['smtp_generic_map_entries'].empty? template "#{node['postfix']['conf_dir']}/smtp_generic" do owner 'root' group node['root_group'] - mode '0644' + mode '0644' notifies :run, 'execute[update-postfix-smtp_generic]' notifies :reload, 'service[postfix]' end diff --git a/recipes/aliases.rb b/recipes/aliases.rb index cd2eb3c..bbecd1d 100644 --- a/recipes/aliases.rb +++ b/recipes/aliases.rb @@ -20,7 +20,7 @@ execute 'update-postfix-aliases' do command 'newaliases' environment PATH: "#{ENV['PATH']}:/opt/omni/bin:/opt/omni/sbin" if platform_family?('omnios') # On FreeBSD, /usr/sbin/newaliases is the sendmail command, and it's in the path before postfix's /usr/local/bin/newaliases - environment ({ 'PATH' => "/usr/local/bin:#{ENV['PATH']}" }) if platform_family?('freebsd') + environment('PATH' => "/usr/local/bin:#{ENV['PATH']}") if platform_family?('freebsd') action :nothing end diff --git a/recipes/default.rb b/recipes/default.rb index ba28cdc..adfab98 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -20,31 +20,16 @@ include_recipe 'postfix::_common' -if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes' - include_recipe 'postfix::sasl_auth' -end +include_recipe 'postfix::sasl_auth' if node['postfix']['main']['smtp_sasl_auth_enable'] == 'yes' -if node['postfix']['use_alias_maps'] - include_recipe 'postfix::aliases' -end +include_recipe 'postfix::aliases' if node['postfix']['use_alias_maps'] -if node['postfix']['use_transport_maps'] - include_recipe 'postfix::transports' -end +include_recipe 'postfix::transports' if node['postfix']['use_transport_maps'] -if node['postfix']['use_access_maps'] - include_recipe 'postfix::access' -end +include_recipe 'postfix::access' if node['postfix']['use_access_maps'] -if node['postfix']['use_virtual_aliases'] - include_recipe 'postfix::virtual_aliases' -end +include_recipe 'postfix::virtual_aliases' if node['postfix']['use_virtual_aliases'] -if node['postfix']['use_virtual_aliases_domains'] - include_recipe 'postfix::virtual_aliases_domains' -end - -if node['postfix']['use_relay_restrictions_maps'] - include_recipe 'postfix::relay_restrictions' -end +include_recipe 'postfix::virtual_aliases_domains' if node['postfix']['use_virtual_aliases_domains'] +include_recipe 'postfix::relay_restrictions' if node['postfix']['use_relay_restrictions_maps'] diff --git a/recipes/relay_restrictions.rb b/recipes/relay_restrictions.rb index a96d482..fe4e557 100644 --- a/recipes/relay_restrictions.rb +++ b/recipes/relay_restrictions.rb @@ -26,4 +26,3 @@ template node['postfix']['relay_restrictions_db'] do source 'relay_restrictions.erb' notifies :run, 'execute[update-postfix-relay-restrictions]' end - diff --git a/spec/wrapper_spec.rb b/spec/wrapper_spec.rb index 9820302..2084e39 100644 --- a/spec/wrapper_spec.rb +++ b/spec/wrapper_spec.rb @@ -15,6 +15,7 @@ describe 'wrapper::default' do expect(chef_run.node['postfix']['main']['relayhost']).to eq('please') expect(chef_run.node['postfix']['main']['smtp_sasl_security_options']).to eq('keep') expect(chef_run.node['postfix']['sasl']['smtp_sasl_user_name']).to eq('us') + expect(chef_run.node['postfix']['sasl']['smtp_sasl_passwd']).to eq('happy') end end end diff --git a/test/fixtures/cookbooks/wrapper/attributes/default.rb b/test/fixtures/cookbooks/wrapper/attributes/default.rb index 6ea324e..10c20e0 100644 --- a/test/fixtures/cookbooks/wrapper/attributes/default.rb +++ b/test/fixtures/cookbooks/wrapper/attributes/default.rb @@ -1,6 +1,8 @@ - -default['postfix']['main']['smtp_sasl_auth_enable'] = 'yes' - -default['postfix']['main']['relayhost'] = 'please' -default['postfix']['sasl']['smtp_sasl_user_name'] = 'keep' -default['postfix']['sasl']['smtp_sasl_passwd'] = 'us' + +default['postfix']['main']['smtp_sasl_auth_enable'] = 'yes' + +default['postfix']['main']['relayhost'] = 'please' +default['postfix']['main']['smtp_sasl_security_options'] = 'keep' +default['postfix']['sasl']['smtp_sasl_user_name'] = 'us' +default['postfix']['sasl']['smtp_sasl_passwd'] = 'happy' +default['postfix']['sender_canonical_map_entries'] = {} diff --git a/test/fixtures/cookbooks/wrapper/metadata.rb b/test/fixtures/cookbooks/wrapper/metadata.rb index e92f14f..14d7590 100644 --- a/test/fixtures/cookbooks/wrapper/metadata.rb +++ b/test/fixtures/cookbooks/wrapper/metadata.rb @@ -1,3 +1,4 @@ name 'wrapper' version '0.0.1' description 'Wrapper cookbook, used for testing only.' +depends 'postfix' diff --git a/test/fixtures/cookbooks/wrapper/recipes/default.rb b/test/fixtures/cookbooks/wrapper/recipes/default.rb index 6bd393a..51a1cb3 100644 --- a/test/fixtures/cookbooks/wrapper/recipes/default.rb +++ b/test/fixtures/cookbooks/wrapper/recipes/default.rb @@ -1,2 +1,2 @@ -include 'postfix' +include_recipe 'postfix' diff --git a/test/integration/helpers/serverspec/spec_helper.rb b/test/integration/helpers/serverspec/spec_helper.rb index fb6f099..66b445e 100644 --- a/test/integration/helpers/serverspec/spec_helper.rb +++ b/test/integration/helpers/serverspec/spec_helper.rb @@ -3,25 +3,24 @@ require 'serverspec' set :backend, :exec set :path, '/sbin:/usr/local/sbin:$PATH' -def get_family +def which_family fam = 'solaris2' return fam unless File.exist? '/etc/release' - File.open("/etc/release") do |file| - while line = file.gets - case line - when /^\s*(OmniOS)/ - fam = 'omnios' - end + File.open('/etc/release') do |file| + while (line = file.gets) + case line + when /^\s*(OmniOS)/ + fam = 'omnios' end + end end fam end def postfix_conf_path - if os[:family] == 'solaris' && get_family == 'omnios' + if os[:family] == 'solaris' && which_family == 'omnios' '/opt/omni/etc/postfix/' else '/etc/postfix' end end -