File: should_not_run_command_creates.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (39 lines) | stat: -rw-r--r-- 1,360 bytes parent folder | download | duplicates (2)
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
test_name "should not run command creates"
tag 'audit:high',
    'audit:refactor',   # Use block style `test_name`
    'audit:acceptance'

agents.each do |agent|
  touch      = agent.tmpfile('touched')
  donottouch = agent.tmpfile('not-touched')

manifest = %Q{
  exec { "test#{Time.new.to_i}": command => '#{agent.touch(donottouch)}', creates => "#{touch}"}
}

  step "prepare the agents for the test"
  on agent, "touch #{touch} && rm -f #{donottouch}"

  step "test using puppet apply"
  apply_manifest_on(agent, manifest) do |result|
    fail_test "looks like the thing executed, which it shouldn't" if
      result.stdout.include? 'executed successfully'
  end

  step "verify the file didn't get created"
  on agent, "test -f #{donottouch}", :acceptable_exit_codes => [1]

  step "prepare the agents for the second part of the test"
  on agent, "touch #{touch} ; rm -f #{donottouch}"

  step "test using puppet resource"
  on(agent, puppet_resource('exec', "test#{Time.new.to_i}",
                   "command='#{agent.touch(donottouch)}'",
                   "creates='#{touch}'")) do |result|
    fail_test "looks like the thing executed, which it shouldn't" if
      result.stdout.include? 'executed successfully'
  end

  step "verify the file didn't get created the second time"
  on agent, "test -f #{donottouch}", :acceptable_exit_codes => [1]
end