1
test_name "#8740: should not enumerate root directory"
3
target = "/test-socket-#{$$}"
5
step "clean up the system before we begin"
6
on(agents, "rm -f #{target}")
8
step "create UNIX domain socket"
9
on(agents, %Q{ruby -e "require 'socket'; UNIXServer::new('#{target}').close"})
11
step "query for all files, which should return nothing"
12
on(agents, puppet_resource('file'), :acceptable_exit_codes => [1]) do
13
assert_match(%r{Listing all file instances is not supported. Please specify a file or directory, e.g. puppet resource file /etc}, stderr)
16
["/", "/etc"].each do |file|
17
step "query '#{file}' directory, which should return single entry"
18
on(agents, puppet_resource('file', file)) do
19
files = stdout.scan(/^file \{ '([^']+)'/).flatten
21
assert_equal(1, files.size, "puppet returned multiple files: #{files.join(', ')}")
22
assert_match(file, files[0], "puppet did not return file")
26
step "query file that does not exist, which should report the file is absent"
27
on(agents, puppet_resource('file', '/this/does/notexist')) do
28
assert_match(/ensure\s+=>\s+'absent'/, stdout)
31
step "remove UNIX domain socket"
32
on(agents, "rm -f #{target}")