summaryrefslogtreecommitdiffstats
path: root/acceptance/tests/resource/group/should_query_all.rb
blob: 9abcfed21b439027bb0d4198821d0bd4dad8ee14 (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 "puppet resource should query all groups"

agents.each do |host|
    groups = {}

    step "collect the list of groups on #{host} with getent group"
    on(host, "getent group") do
        stdout.each_line do |line| groups[line[/^[^:]+/]] = 'getent' end
    end

    step "collect the list of groups on #{host} with puppet resource"
    on(host, puppet_resource('group')) do
        stdout.each_line do |line|
            match = line.match(/^group \{ '([^']+)'/)
            if match then
                name = match[1]

                if groups.include? name then
                    groups.delete name
                else
                    fail_test "group #{name} found by puppet, not getent"
                end
            end
        end
    end

    groups.keys.each do |name|
        fail_test "group #{name} found by getent, not puppet"
    end
end