mirror of
https://github.com/inspec/inspec
synced 2024-12-11 22:02:47 +00:00
6c3ab70dd1
* json resource (et. al.): allow inspec check to succeed when using command When using the `json` resource (or any of the resources that subclass JsonConfig), `inspec check` would fail if the content was supplied with the `command` option. This is because the `command` resource is mocked and an empty string would be returned for `stdout`. That content would be blindly passed to the `parse` method would which raise an exception and cause `inspec check` to fail. This change refactors JsonConfig to be a bit cleaner and use some helper methods. Additionally, we use the new Exceptions to properly raise errors which are naturally caught by Inspec::Profile, etc. Signed-off-by: Adam Leff <adam@leff.co> * Make `resource_base_name` method private Signed-off-by: Adam Leff <adam@leff.co>
29 lines
676 B
Ruby
29 lines
676 B
Ruby
# encoding: utf-8
|
|
# author: Christoph Hartmann
|
|
# author: Dominik Richter
|
|
|
|
require 'utils/simpleconfig'
|
|
|
|
module Inspec::Resources
|
|
class IniConfig < JsonConfig
|
|
name 'ini'
|
|
desc 'Use the ini InSpec audit resource to test data in a INI file.'
|
|
example "
|
|
descibe ini do
|
|
its('auth_protocol') { should eq 'https' }
|
|
end
|
|
"
|
|
# override file load and parse hash with simple config
|
|
def parse(content)
|
|
SimpleConfig.new(content).params
|
|
end
|
|
|
|
private
|
|
|
|
# used by JsonConfig to build up a full to_s method
|
|
# based on whether a file path, content, or command was supplied.
|
|
def resource_base_name
|
|
'INI'
|
|
end
|
|
end
|
|
end
|