2015-10-06 12:47:37 +00:00
|
|
|
# encoding: utf-8
|
2015-10-07 10:10:59 +00:00
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
2015-10-06 12:47:37 +00:00
|
|
|
|
|
|
|
require 'helper'
|
2015-10-26 03:04:18 +00:00
|
|
|
require 'inspec/resource'
|
2015-10-06 12:47:37 +00:00
|
|
|
|
2015-10-26 03:04:18 +00:00
|
|
|
describe 'Inspec::Resources::Group' do
|
2015-10-06 12:47:37 +00:00
|
|
|
|
|
|
|
# ubuntu 14.04
|
|
|
|
it 'verify group on ubuntu' do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'root')
|
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
_(resource.gid).must_equal 0
|
|
|
|
_(resource.has_gid?(0)).must_equal true
|
|
|
|
end
|
|
|
|
|
2017-08-30 20:02:45 +00:00
|
|
|
it 'verify group on ubuntu with mixed case' do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'GroupWithCaps')
|
2015-10-07 10:04:48 +00:00
|
|
|
_(resource.exists?).must_equal true
|
2017-08-30 20:02:45 +00:00
|
|
|
_(resource.gid).must_equal 999
|
|
|
|
_(resource.has_gid?(999)).must_equal true
|
2015-10-07 10:04:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# ubuntu with non-existent group
|
|
|
|
it 'verify group on ubuntu' do
|
|
|
|
resource = MockLoader.new(:ubuntu1404).load_resource('group', 'nogroup')
|
|
|
|
_(resource.exists?).must_equal false
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.gid).must_be_nil
|
2015-10-07 10:04:48 +00:00
|
|
|
_(resource.has_gid?(0)).must_equal false
|
|
|
|
end
|
|
|
|
|
2015-10-06 12:47:37 +00:00
|
|
|
# mac
|
|
|
|
it 'verify group on mac' do
|
|
|
|
resource = MockLoader.new(:osx104).load_resource('group', 'root')
|
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
_(resource.gid).must_equal 0
|
|
|
|
_(resource.has_gid?(0)).must_equal true
|
|
|
|
end
|
2015-10-06 12:50:55 +00:00
|
|
|
|
2015-10-07 10:04:48 +00:00
|
|
|
# freebsd
|
|
|
|
it 'verify group on freebsd' do
|
|
|
|
resource = MockLoader.new(:freebsd10).load_resource('group', 'root')
|
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
_(resource.gid).must_equal 0
|
|
|
|
_(resource.has_gid?(0)).must_equal true
|
|
|
|
end
|
|
|
|
|
|
|
|
# windows with local group
|
2018-05-31 17:37:44 +00:00
|
|
|
it 'verify administrator group on windows' do
|
2015-10-07 10:04:48 +00:00
|
|
|
resource = MockLoader.new(:windows).load_resource('group', 'Administrators')
|
|
|
|
_(resource.exists?).must_equal true
|
2016-09-22 21:45:28 +00:00
|
|
|
_(resource.gid).must_equal 'S-1-5-32-544'
|
2015-10-07 10:04:48 +00:00
|
|
|
_(resource.has_gid?(0)).must_equal false
|
2018-05-31 17:37:44 +00:00
|
|
|
_(resource.members).must_equal ['Administrators', 'Domain Admins']
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'verify power users group on windows' do
|
|
|
|
resource = MockLoader.new(:windows).load_resource('group', 'Power Users')
|
|
|
|
_(resource.exists?).must_equal true
|
|
|
|
_(resource.gid).must_equal 'S-1-5-32-547'
|
|
|
|
_(resource.has_gid?(0)).must_equal false
|
|
|
|
_(resource.members).must_equal []
|
2015-10-07 10:04:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# windows non-existent group
|
|
|
|
it 'verify non-existing group on windows' do
|
|
|
|
resource = MockLoader.new(:windows).load_resource('group', 'dhcp')
|
|
|
|
_(resource.exists?).must_equal false
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.gid).must_be_nil
|
2015-10-07 10:04:48 +00:00
|
|
|
_(resource.has_gid?(0)).must_equal false
|
2018-05-31 17:37:44 +00:00
|
|
|
_(resource.members).must_equal nil
|
2015-10-07 10:04:48 +00:00
|
|
|
end
|
|
|
|
|
2015-10-06 12:50:55 +00:00
|
|
|
# undefined
|
|
|
|
it 'verify package handling on unsupported os' do
|
|
|
|
resource = MockLoader.new(:undefined).load_resource('group', 'root')
|
|
|
|
_(resource.exists?).must_equal false
|
2017-06-11 10:16:10 +00:00
|
|
|
_(resource.gid).must_be_nil
|
2015-10-06 12:50:55 +00:00
|
|
|
_(resource.has_gid?(0)).must_equal false
|
|
|
|
end
|
2015-10-06 12:47:37 +00:00
|
|
|
end
|