mirror of
https://github.com/inspec/inspec
synced 2024-11-10 15:14:23 +00:00
Improve testing on inputs that do not have values (#4007)
Improve testing on inputs that do not have values
This commit is contained in:
commit
80b847ae83
3 changed files with 46 additions and 0 deletions
|
@ -107,4 +107,14 @@ describe 'inputs' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'when using a profile with undeclared (valueless) inputs' do
|
||||
it 'should warn about them and not abort the run' do
|
||||
cmd = "exec #{inputs_profiles_path}/undeclared"
|
||||
result = run_inspec_process(cmd, json: true)
|
||||
result.stderr.must_include "WARN: Input 'undeclared_01'"
|
||||
result.stderr.must_include 'does not have a value'
|
||||
result.must_have_all_controls_passing
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
control 'start_marker' do
|
||||
describe('dummy_test_01') do
|
||||
it { should cmp 'dummy_test_01'}
|
||||
end
|
||||
end
|
||||
|
||||
control 'undeclared_in_control_body' do
|
||||
attribute('undeclared_01')
|
||||
assignment_outcome = attribute('undeclared_02')
|
||||
describe('dummy_test_02') do
|
||||
it { should cmp 'dummy_test_02'}
|
||||
end
|
||||
end
|
||||
|
||||
control 'undeclared_in_only_if' do
|
||||
only_if { attribute('undeclared_03') }
|
||||
describe('dummy_test_03') do
|
||||
it { should cmp 'dummy_test_03'}
|
||||
end
|
||||
end
|
||||
|
||||
attribute('undeclared_04')
|
||||
|
||||
control 'end_marker' do
|
||||
describe('dummy_test_04') do
|
||||
it { should cmp 'dummy_test_04'}
|
||||
end
|
||||
end
|
8
test/unit/mock/profiles/inputs/undeclared/inspec.yml
Normal file
8
test/unit/mock/profiles/inputs/undeclared/inspec.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
name: undeclared_attribute
|
||||
title: InSpec Profile
|
||||
maintainer: The Authors
|
||||
copyright: The Authors
|
||||
copyright_email: you@example.com
|
||||
license: Apache-2.0
|
||||
summary: A profile mentioning an attribute in a control file that has not otherwise been mentioned
|
||||
version: 0.1.0
|
Loading…
Reference in a new issue