Improve testing on inputs that do not have values (#4007)

Improve testing on inputs that do not have values
This commit is contained in:
Clinton Wolfe 2019-05-07 15:01:09 -04:00 committed by GitHub
commit 80b847ae83
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 0 deletions

View file

@ -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

View file

@ -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

View 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