mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
improvement: return gids in etc_group as integer
This commit is contained in:
parent
3e9526d992
commit
e57505739e
2 changed files with 6 additions and 4 deletions
|
@ -21,9 +21,11 @@
|
|||
# its('users') { should include 'my_user' }
|
||||
# end
|
||||
|
||||
require 'utils/convert'
|
||||
require 'utils/parser'
|
||||
|
||||
class EtcGroup < Vulcano.resource(1)
|
||||
include Converter
|
||||
include ContentParser
|
||||
|
||||
name 'etc_group'
|
||||
|
@ -49,7 +51,7 @@ class EtcGroup < Vulcano.resource(1)
|
|||
|
||||
def gids(filter = nil)
|
||||
entries = filter || @entries
|
||||
entries.map { |x| x[2] } if !entries.nil?
|
||||
entries.map { |x| convert_to_i(x[2]) } if !entries.nil?
|
||||
end
|
||||
|
||||
def users(filter = nil)
|
||||
|
|
|
@ -9,21 +9,21 @@ describe 'Vulcano::Resources::EtcGroup' do
|
|||
let(:resource) { load_resource('etc_group') }
|
||||
|
||||
it 'verify /etc/group config parsing' do
|
||||
_(resource.gids).must_equal %w{ 0 33 }
|
||||
_(resource.gids).must_equal [0, 33]
|
||||
_(resource.groups).must_equal %w{ root www-data }
|
||||
_(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.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.gids).must_equal [33]
|
||||
_(www_filter.groups).must_equal ['www-data']
|
||||
_(www_filter.users).must_equal ['www-data', 'root']
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue