add unit tests for user resource that cover ldap groups

This commit is contained in:
Christoph Hartmann 2015-11-24 16:18:55 +01:00
parent 0bd7f557d5
commit 9231833cad
4 changed files with 19 additions and 0 deletions

View file

@ -157,6 +157,10 @@ class MockLoader
'id root' => cmd.call('id-root'),
'getent passwd root' => cmd.call('getent-passwd-root'),
'chage -l root' => cmd.call('chage-l-root'),
# user information for ldap test
'id jfolmer' => cmd.call('id-jfolmer'),
'getent passwd jfolmer' => cmd.call('getent-passwd-jfolmer'),
'chage -l jfolmer' => cmd.call('chage-l-root'),
# user info for mac
'id chartmann' => cmd.call('id-chartmann'),
'dscl -q . -read /Users/chartmann NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell' => cmd.call('dscl'),

View file

@ -0,0 +1 @@
jfolmer:x:0:0:jfolmer:/jfolmer:/bin/bash

View file

@ -0,0 +1 @@
uid=201105(jfolmer) gid=200513(domain users) groups=200513(domain users),200512(domain admins),200572(denied rodc password replication group)

View file

@ -20,6 +20,19 @@ describe 'Inspec::Resources::User' do
_(resource.warndays).must_equal 7
end
# ubuntu 14.04 test with ldap user
it 'read user on ubuntu' do
resource = MockLoader.new(:ubuntu1404).load_resource('user', 'jfolmer')
_(resource.exists?).must_equal true
_(resource.group).must_equal 'domain users'
_(resource.groups).must_equal ['domain users', 'domain admins', 'denied rodc password replication group']
_(resource.home).must_equal '/jfolmer'
_(resource.shell).must_equal '/bin/bash'
_(resource.mindays).must_equal 0
_(resource.maxdays).must_equal 99999
_(resource.warndays).must_equal 7
end
# serverspec compatibility tests (do not test matcher)
it 'verify serverspec compatibility' do
resource = MockLoader.new(:ubuntu1404).load_resource('user', 'root')