mirror of
https://github.com/inspec/inspec
synced 2024-12-04 18:39:43 +00:00
49d36de0f3
* Allow `inspec check` to ignore `only_if` When using `inspec check` a mock Train backend is created. This means that the following would raise an error because `os.name` is `nil` ``` only_if { os.name.include?('anything') } ``` Since `inspec check` isn't concerned with the evaluation of `only_if` this skips those checks if the block given raises an error. Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Remove unnecessary `e` in rescue Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Modify implementation to use `check_mode` Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Move `check_mode` concept to the Profile scope Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Fix lint after rubocop upgrade Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com> * Add comment for mocked ControlEvalContext options Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
39 lines
1.2 KiB
Ruby
39 lines
1.2 KiB
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
require 'functional/helper'
|
|
require 'jsonschema'
|
|
|
|
describe 'inspec check' do
|
|
include FunctionalHelper
|
|
|
|
describe 'inspec check with json formatter' do
|
|
it 'can check a profile and produce valid JSON' do
|
|
out = inspec('check ' + integration_test_path + ' --format json')
|
|
out.exit_status.must_equal 0
|
|
JSON.parse(out.stdout)
|
|
end
|
|
end
|
|
|
|
describe 'inspec check with special characters in path' do
|
|
it 'can check a profile with special characters in its path' do
|
|
out = inspec('check ' + File.join(profile_path, '{{special-path}}'))
|
|
out.exit_status.must_equal 0
|
|
end
|
|
end
|
|
|
|
describe 'inspec check with skipping/failing a resource in FilterTable' do
|
|
it 'can check a profile with special characters in its path' do
|
|
out = inspec('check ' + File.join(profile_path, 'profile-with-resource-exceptions'))
|
|
out.exit_status.must_equal 0
|
|
end
|
|
end
|
|
|
|
describe 'inspec check with a profile containing only_if' do
|
|
it 'ignores the `only_if`' do
|
|
out = inspec('check ' + File.join(profile_path, 'only-if-os-nope'))
|
|
out.exit_status.must_equal 0
|
|
end
|
|
end
|
|
end
|