mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
c383175417
* Support mixed-case group entries The `group` resource downcased the input parameter unless the target was a Windows node. However, it's completely legitimate for a Unix-y node to have mixed case group and passwd entries. This change does have the potential to break people that did not carefully match their case when searching for a group, but we're currently blocking people from using the group resource properly if they have mixed-case entries. Signed-off-by: Adam Leff <adam@leff.co> * Fix unit tests Signed-off-by: Adam Leff <adam@leff.co>
37 lines
1.1 KiB
Ruby
37 lines
1.1 KiB
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
|
|
require 'helper'
|
|
require 'inspec/resource'
|
|
|
|
describe 'Inspec::Resources::EtcGroup' do
|
|
let(:resource) { load_resource('etc_group') }
|
|
|
|
it 'verify /etc/group config parsing' do
|
|
_(resource.gids).must_equal [0, 33, 999]
|
|
_(resource.groups).must_equal %w{ root www-data GroupWithCaps }
|
|
_(resource.users).must_equal %w{ www-data root }
|
|
end
|
|
|
|
it 'verify group filter with no users' do
|
|
root_filter = resource.where(name: 'root')
|
|
_(root_filter.gids).must_equal [0]
|
|
_(root_filter.groups).must_equal ['root']
|
|
_(root_filter.users).must_equal []
|
|
end
|
|
|
|
it 'verify group filter with users' do
|
|
www_filter = resource.where(name: 'www-data')
|
|
_(www_filter.gids).must_equal [33]
|
|
_(www_filter.groups).must_equal ['www-data']
|
|
_(www_filter.users).must_equal ['www-data', 'root']
|
|
end
|
|
|
|
it 'verify group filter with wrong group' do
|
|
wrong_filter = resource.where(name: 'wrong_group')
|
|
_(wrong_filter.gids).must_equal []
|
|
_(wrong_filter.groups).must_equal []
|
|
_(wrong_filter.users).must_equal []
|
|
end
|
|
end
|