summaryrefslogtreecommitdiffstats
path: root/acceptance/tests/resource/user/should_query_all.rb
blob: 00d7b25c449660e957204f82777d173db91d7442 (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
test_name "ensure that puppet queries the correct number of users"

agents.each do |host|
    users = []

    step "collect the list of known users via getent"
    on(host, "getent passwd") do
        stdout.each_line do |line|
            users << line.split(':')[0]
        end
    end

    step "collect the list of known users via puppet"
    on(host, puppet_resource('user')) do
        stdout.each_line do |line|
            name = ( line.match(/^user \{ '([^']+)'/) or next )[1]

            # OK: Was this name found in the list of users?
            if users.member? name then
                users.delete name
            else
                fail_test "user #{name} found by puppet, not by getent"
            end
        end
    end

    if users.length > 0 then
        fail_test "#{users.length} users found with getent, not puppet: #{users.join(', ')}"
    end
end