Class: Inspec::Resources::Group

Inherits:
Object
  • Object
show all
Includes:
GroupManagementSelector
Defined in:
lib/inspec/resources/groups.rb

Overview

Usage: describe group(‘root’) do

it { should exist }
its('gid') { should eq 0 }

end

Instance Method Summary collapse

Methods included from GroupManagementSelector

#select_group_manager

Constructor Details

#initialize(groupname) ⇒ Group

Returns a new instance of Group.



96
97
98
99
100
101
102
# File 'lib/inspec/resources/groups.rb', line 96

def initialize(groupname)
  @group = groupname

  # select group manager
  @group_provider = select_group_manager(inspec.os)
  return skip_resource "The `group` resource is not supported on your OS yet." if @group_provider.nil?
end

Instance Method Details

#exists?Boolean

verifies if a group exists

Returns:

  • (Boolean)


105
106
107
# File 'lib/inspec/resources/groups.rb', line 105

def exists?
  !group_info.entries.empty?
end

#gidObject



109
110
111
# File 'lib/inspec/resources/groups.rb', line 109

def gid
  flatten_entry(group_info, "gid")
end

#localObject



117
118
119
120
# File 'lib/inspec/resources/groups.rb', line 117

def local
  # at this point the implementation only returns local groups
  true
end

#membersObject



113
114
115
# File 'lib/inspec/resources/groups.rb', line 113

def members
  flatten_entry(group_info, "members")
end

#to_sObject



122
123
124
# File 'lib/inspec/resources/groups.rb', line 122

def to_s
  "Group #{@group}"
end