2015-09-05 22:25:25 +02:00
|
|
|
# encoding: utf-8
|
2015-10-06 18:55:44 +02:00
|
|
|
# author: Christoph Hartmann
|
|
|
|
# author: Dominik Richter
|
2015-09-05 22:25:25 +02:00
|
|
|
|
|
|
|
require 'helper'
|
2015-10-26 04:04:18 +01:00
|
|
|
require 'inspec/resource'
|
2015-09-05 22:25:25 +02:00
|
|
|
|
2015-10-26 04:04:18 +01:00
|
|
|
describe 'Inspec::Resources::EtcGroup' do
|
2015-09-22 18:31:21 +02:00
|
|
|
let(:resource) { load_resource('etc_group') }
|
2015-09-05 22:25:25 +02:00
|
|
|
|
2015-09-22 18:33:05 +02:00
|
|
|
it 'verify /etc/group config parsing' do
|
2015-10-06 14:00:19 +02:00
|
|
|
_(resource.gids).must_equal [0, 33]
|
2015-09-22 18:33:05 +02:00
|
|
|
_(resource.groups).must_equal %w{ root www-data }
|
|
|
|
_(resource.users).must_equal %w{ www-data root }
|
|
|
|
end
|
2015-09-05 22:25:25 +02:00
|
|
|
|
2015-09-22 18:33:05 +02:00
|
|
|
it 'verify group filter with no users' do
|
|
|
|
root_filter = resource.where(name: 'root')
|
2015-10-06 14:00:19 +02:00
|
|
|
_(root_filter.gids).must_equal [0]
|
2015-09-22 18:33:05 +02:00
|
|
|
_(root_filter.groups).must_equal ['root']
|
|
|
|
_(root_filter.users).must_equal []
|
|
|
|
end
|
2015-09-05 22:25:25 +02:00
|
|
|
|
2015-09-22 18:33:05 +02:00
|
|
|
it 'verify group filter with users' do
|
|
|
|
www_filter = resource.where(name: 'www-data')
|
2015-10-06 14:00:19 +02:00
|
|
|
_(www_filter.gids).must_equal [33]
|
2015-09-22 18:33:05 +02:00
|
|
|
_(www_filter.groups).must_equal ['www-data']
|
|
|
|
_(www_filter.users).must_equal ['www-data', 'root']
|
|
|
|
end
|
2015-09-05 22:25:25 +02:00
|
|
|
|
2015-09-22 18:33:05 +02:00
|
|
|
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 []
|
2015-09-05 22:25:25 +02:00
|
|
|
end
|
|
|
|
end
|