|
| 1 | +test_name "should be able to handle fifo files" |
| 2 | +tag 'audit:high', |
| 3 | + 'audit:acceptance' |
| 4 | +confine :except, :platform => /windows/ |
| 5 | + |
| 6 | +def ensure_content_to_file_manifest(file_path, ensure_value) |
| 7 | + return <<-MANIFEST |
| 8 | + file { "#{file_path}": |
| 9 | + ensure => #{ensure_value}, |
| 10 | + content => "Hello World" |
| 11 | + } |
| 12 | + MANIFEST |
| 13 | +end |
| 14 | + |
| 15 | +agents.each do |agent| |
| 16 | + tmp_path = agent.tmpdir("tmpdir") |
| 17 | + fifo_path = "#{tmp_path}/myfifo" |
| 18 | + |
| 19 | + teardown do |
| 20 | + agent.rm_rf(tmp_path) |
| 21 | + end |
| 22 | + |
| 23 | + step "create fifo" do |
| 24 | + on(agent, "mkfifo #{fifo_path}") |
| 25 | + end |
| 26 | + |
| 27 | + step "check that fifo got created" do |
| 28 | + on(agent, "ls -l #{fifo_path}") do |result| |
| 29 | + assert(result.stdout.start_with?('p')) |
| 30 | + end |
| 31 | + end |
| 32 | + |
| 33 | + step "puppet ensures given fifo is present" do |
| 34 | + apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'present'), :acceptable_exit_codes => [2]) do |
| 35 | + assert_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr) |
| 36 | + end |
| 37 | + end |
| 38 | + |
| 39 | + step "check that given file is still a fifo" do |
| 40 | + on(agent, "ls -l #{fifo_path}") do |result| |
| 41 | + assert(result.stdout.start_with?('p')) |
| 42 | + end |
| 43 | + end |
| 44 | + |
| 45 | + step "puppet ensures given fifo is a regular file" do |
| 46 | + apply_manifest_on(agent, ensure_content_to_file_manifest(fifo_path, 'file'), :acceptable_exit_codes => [0]) do |
| 47 | + assert_match(/Notice: .+\/myfifo\]\/ensure: defined content as '{/, stdout) |
| 48 | + assert_no_match(/Warning: .+ Ensure set to :present but file type is fifo so no content will be synced/, stderr) |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + step "check that given fifo is now a regular file" do |
| 53 | + on(agent, "ls -l #{fifo_path}") do |result| |
| 54 | + assert(result.stdout.start_with?('-')) |
| 55 | + end |
| 56 | + end |
| 57 | + |
| 58 | + step "check that given file now has desired content" do |
| 59 | + on(agent, "cat #{fifo_path}") do |result| |
| 60 | + assert_equal('Hello World', result.stdout) |
| 61 | + end |
| 62 | + end |
| 63 | +end |
0 commit comments