mirror of
https://github.com/inspec/inspec
synced 2024-11-23 21:23:29 +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' }
|
# its('users') { should include 'my_user' }
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
require 'utils/convert'
|
||||||
require 'utils/parser'
|
require 'utils/parser'
|
||||||
|
|
||||||
class EtcGroup < Vulcano.resource(1)
|
class EtcGroup < Vulcano.resource(1)
|
||||||
|
include Converter
|
||||||
include ContentParser
|
include ContentParser
|
||||||
|
|
||||||
name 'etc_group'
|
name 'etc_group'
|
||||||
|
@ -49,7 +51,7 @@ class EtcGroup < Vulcano.resource(1)
|
||||||
|
|
||||||
def gids(filter = nil)
|
def gids(filter = nil)
|
||||||
entries = filter || @entries
|
entries = filter || @entries
|
||||||
entries.map { |x| x[2] } if !entries.nil?
|
entries.map { |x| convert_to_i(x[2]) } if !entries.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
def users(filter = nil)
|
def users(filter = nil)
|
||||||
|
|
|
@ -9,21 +9,21 @@ describe 'Vulcano::Resources::EtcGroup' do
|
||||||
let(:resource) { load_resource('etc_group') }
|
let(:resource) { load_resource('etc_group') }
|
||||||
|
|
||||||
it 'verify /etc/group config parsing' do
|
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.groups).must_equal %w{ root www-data }
|
||||||
_(resource.users).must_equal %w{ www-data root }
|
_(resource.users).must_equal %w{ www-data root }
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'verify group filter with no users' do
|
it 'verify group filter with no users' do
|
||||||
root_filter = resource.where(name: 'root')
|
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.groups).must_equal ['root']
|
||||||
_(root_filter.users).must_equal []
|
_(root_filter.users).must_equal []
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'verify group filter with users' do
|
it 'verify group filter with users' do
|
||||||
www_filter = resource.where(name: 'www-data')
|
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.groups).must_equal ['www-data']
|
||||||
_(www_filter.users).must_equal ['www-data', 'root']
|
_(www_filter.users).must_equal ['www-data', 'root']
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue