Class: Inspec::Resources::Routingtable
- Inherits:
-
Object
- Object
- Inspec::Resources::Routingtable
- Defined in:
- lib/inspec/resources/routing_table.rb
Direct Known Subclasses
Instance Method Summary collapse
- #has_entry?(input_route) ⇒ Boolean
-
#initialize ⇒ Routingtable
constructor
A new instance of Routingtable.
-
#to_s ⇒ Object
resource appearance in test reports.
Constructor Details
#initialize ⇒ Routingtable
Returns a new instance of Routingtable.
31 32 33 34 35 36 |
# File 'lib/inspec/resources/routing_table.rb', line 31 def initialize skip_resource "The `routing_table` resource is not yet available on your OS." unless inspec.os.unix? || inspec.os.windows? # fetch the routing information and store it in @routing_info (could be hash, tbd) @routing_info = {} fetch_routing_information end |
Instance Method Details
#has_entry?(input_route) ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/inspec/resources/routing_table.rb', line 43 def has_entry?(input_route) # check if the destination, gateway, interface exists as part of the routing_info if input_route.key?(:destination) && input_route.key?(:gateway) && input_route.key?(:interface) # check if there is key with destination's value in hash; # if yes, check if destination and gateway is present else return false @routing_info.key?(input_route[:destination]) ? @routing_info[input_route[:destination]].include?([input_route[:gateway], input_route[:interface]]) : false else raise Inspec::Exceptions::ResourceSkipped, "One or more missing key, have_entry? matcher expects a hash with 3 keys: destination, gateway and interface" end end |
#to_s ⇒ Object
resource appearance in test reports.
39 40 41 |
# File 'lib/inspec/resources/routing_table.rb', line 39 def to_s "routing_table" end |