~ubuntu-branches/ubuntu/trusty/puppet/trusty

« back to all changes in this revision

Viewing changes to acceptance/tests/resource/user/should_query_all.rb

  • Committer: Package Import Robot
  • Author(s): Stig Sandbeck Mathisen
  • Date: 2011-10-22 14:08:22 UTC
  • mfrom: (1.1.25) (3.1.32 sid)
  • Revision ID: package-import@ubuntu.com-20111022140822-odxde5lohc45yhuz
Tags: 2.7.6-1
* New upstream release (CVE-2011-3872)
* Remove cherry-picked "groupadd_aix_warning" patch
* Install all new manpages

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
test_name "ensure that puppet queries the correct number of users"
2
 
 
3
 
agents.each do |host|
4
 
    users = []
5
 
 
6
 
    step "collect the list of known users via getent"
7
 
    on(host, "getent passwd") do
8
 
        stdout.each_line do |line|
9
 
            users << line.split(':')[0]
10
 
        end
11
 
    end
12
 
 
13
 
    step "collect the list of known users via puppet"
14
 
    on(host, puppet_resource('user')) do
15
 
        stdout.each_line do |line|
16
 
            name = ( line.match(/^user \{ '([^']+)'/) or next )[1]
17
 
 
18
 
            # OK: Was this name found in the list of users?
19
 
            if users.member? name then
20
 
                users.delete name
21
 
            else
22
 
                fail_test "user #{name} found by puppet, not by getent"
23
 
            end
24
 
        end
25
 
    end
26
 
 
27
 
    if users.length > 0 then
28
 
        fail_test "#{users.length} users found with getent, not puppet: #{users.join(', ')}"
29
 
    end
30
 
end