aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance/tests/create_spec.rb
blob: 80fe8d32ad6b89e1cc6ebc58d943d1ea830d4e9a (plain)
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
require 'spec_helper_acceptance'

RSpec.context 'Mailalias: should create an email alias' do
  name = "pl#{rand(999_999).to_i}"

  before(:all) do
    non_windows_agents.each do |agent|
      on(agent, 'cp /etc/aliases /tmp/aliases', acceptable_exit_codes: [0, 1])
    end
  end

  after(:all) do
    non_windows_agents.each do |agent|
      on(agent, 'mv /tmp/aliases /etc/aliases', acceptable_exit_codes: [0, 1])
    end
  end

  non_windows_agents.each do |agent|
    it 'creates a mailalias resource' do
      # create a mailalias with puppet
      args = ['ensure=present',
              'recipient="foo,bar,baz"']
      on(agent, puppet_resource('mailalias', name, args))

      # verify the alias exists
      on(agent, 'cat /etc/aliases') do |res|
        assert_match(%r{#{name}:.*foo,bar,baz}, res.stdout, 'mailalias not in aliases file')
      end
    end
  end
end