improvement: return gids in etc_group as integer

This commit is contained in:
Christoph Hartmann 2015-10-06 14:00:19 +02:00
parent 3e9526d992
commit e57505739e
2 changed files with 6 additions and 4 deletions

View file

@ -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)

View file

@ -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