1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# frozen_string_literal: true
require 'spec_helper_acceptance'
describe 'postfix class' do
context 'default parameters' do
it 'works idempotently with no errors' do
pp = <<-EOS
# Make sure the default mailer is stopped in docker containers
if fact('os.name') == 'Debian' {
service { 'exim4':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
if fact('os.family') == 'RedHat' {
service { 'sendmail':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
class { 'postfix':
smtp_listen => 'all',
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe package('postfix') do
it { is_expected.to be_installed }
end
describe service('postfix') do
it { is_expected.to be_enabled }
it { is_expected.to be_running }
end
describe file('/etc/aliases', '/usr/bin/mailx') do
it { is_expected.to exist }
end
end
context 'default parameters with manage_aliase as false' do
it 'works idempotently with no errors and with your own configuration of /etc/aliases' do
pp = <<-EOS
# Make sure the default mailer is stopped in docker containers
if fact('os.name') == 'Debian' {
service { 'exim4':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
if fact('os.family') == 'RedHat' {
service { 'sendmail':
ensure => stopped,
hasstatus => false,
before => Class['postfix'],
}
}
class { 'postfix':
smtp_listen => 'all',
manage_aliases => false,
}
EOS
# Run it twice and test for idempotency
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
end
end
|