postfix_spec.rb 2.57 KB
Newer Older
1
2
3
require 'spec_helper'

describe 'postfix' do
Raphaël Pinson's avatar
Raphaël Pinson committed
4
5
6
7
8
9
10
11
12
13
14
  context 'when using defaults' do
    context 'when on Debian' do
      let (:facts) { {
        :operatingsystem => 'Debian',
        :osfamily        => 'Debian',
        :fqdn            => 'fqdn.example.com',
      } }

      it { should contain_package('postfix') }
      it { should contain_package('mailx') }

Raphaël Pinson's avatar
Raphaël Pinson committed
15
16
      it { should contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") }
      it { should contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") }
Raphaël Pinson's avatar
Raphaël Pinson committed
17
      it { should contain_exec('newaliases').with_refreshonly('true') }
Raphaël Pinson's avatar
Raphaël Pinson committed
18
19
      it { should contain_file('/etc/postfix/master.cf').without('seltype') }
      it { should contain_file('/etc/postfix/main.cf').without('seltype') }
Raphaël Pinson's avatar
Raphaël Pinson committed
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

      it { should contain_postfix__config('myorigin') }
      it { should contain_postfix__config('alias_maps') }
      it { should contain_postfix__config('inet_interfaces') }

      it { should contain_mailalias('root') }

      it {
        should contain_service('postfix').with(
          :ensure    => 'running',
          :enable    => 'true',
          :hasstatus => 'true',
          :restart   => '/etc/init.d/postfix reload'
      ) }
    end

    context 'when on RedHat' do
      let (:facts) { {
        :operatingsystem => 'RedHat',
        :osfamily        => 'RedHat',
        :fqdn            => 'fqdn.example.com',
      } }

      it { should contain_package('postfix') }
      it { should contain_package('mailx') }

Raphaël Pinson's avatar
Raphaël Pinson committed
46
47
      it { should contain_file('/etc/mailname').without('seltype').with_content("fqdn.example.com\n") }
      it { should contain_file('/etc/aliases').without('seltype').with_content("# file managed by puppet\n") }
Raphaël Pinson's avatar
Raphaël Pinson committed
48
      it { should contain_exec('newaliases').with_refreshonly('true') }
Raphaël Pinson's avatar
Raphaël Pinson committed
49
50
      it { should contain_file('/etc/postfix/master.cf').without('seltype') }
      it { should contain_file('/etc/postfix/main.cf').without('seltype') }
Raphaël Pinson's avatar
Raphaël Pinson committed
51
52
53
54
55
56
57
58
59

      it { should contain_postfix__config('myorigin') }
      it { should contain_postfix__config('alias_maps') }
      it { should contain_postfix__config('inet_interfaces') }
      it { should contain_postfix__config('sendmail_path') }
      it { should contain_postfix__config('newaliases_path') }
      it { should contain_postfix__config('mailq_path') }

      it { should contain_mailalias('root') }
60

Raphaël Pinson's avatar
Raphaël Pinson committed
61
62
63
64
65
66
67
68
      it {
        should contain_service('postfix').with(
          :ensure    => 'running',
          :enable    => 'true',
          :hasstatus => 'true',
          :restart   => '/etc/init.d/postfix reload'
      ) }
    end
69
70
  end
end