aboutsummaryrefslogtreecommitdiff
path: root/spec/acceptance/tests/should_modify_alias.rb
blob: f2171f0c3bc0f7768e852d003c33ee2d02b7d86f (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
test_name 'should be able to modify a host alias'

tag 'audit:low',
    'audit:refactor',  # Use block style `test_name`
    'audit:acceptance' # Could be done at the integration (or unit) layer though
# actual changing of resources could irreparably damage a
# host running this, or require special permissions.

agents.each do |agent|
  file = agent.tmpfile('host-modify-alias')

  step 'set up files for the test'
  on agent, "printf '127.0.0.8 test alias\n' > #{file}"

  step 'modify the resource'
  on(agent, puppet_resource('host', 'test', "target=#{file}",
                            'ensure=present', 'ip=127.0.0.8', 'host_aliases=banzai'))

  step 'verify that the content was updated'
  on(agent, "cat #{file}; rm -f #{file}") do
    fail_test 'the alias was not updated' unless
      stdout =~ %r{^127\.0\.0\.8[[:space:]]+test[[:space:]]+banzai[[:space:]]*$}
  end

  step 'clean up after the test'
  on agent, "rm -f #{file}"
end