Updated test for --controls option

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-03-19 12:37:54 +05:30
parent 9a404f5e0f
commit b180914889
2 changed files with 4 additions and 43 deletions

View file

@ -1,5 +1,3 @@
# copyright: 2018, The Authors
control "foo" do
describe 'a thing' do
it { should cmp 'a thing' }
@ -13,13 +11,6 @@ control "bar" do
end
end
control "baz" do
puts 'baz'
describe 'a thing' do
it { should cmp 'a thing' }
end
end
control "11_pass" do
describe 'a thing' do
it { should cmp 'a thing' }
@ -33,37 +24,7 @@ control "11_pass2" do
end
describe 'a thing' do
puts 'only-describe'
it { should cmp 'a thing' }
end
describe.one do
describe 'ConfigurationA' do
it { should cmp 'a thing' }
end
describe 'ConfigurationB' do
it { should cmp 'a thing' }
end
end
title '/ profile'
# you add controls here
control 'tmp-1.0' do # A unique ID for this control
impact 0.7 # The criticality, if this control fails.
title 'Create / directory' # A human-readable title
desc 'An optional description...' # Describe why this is needed
desc 'label', 'An optional description with a label' # Pair a part of the description with a label
tag data: 'temp data' # A tag allows you to associate key information
tag 'security' # to the test
ref 'Document A-12', url: 'http://...' # Additional references
describe file('/') do # The actual test
it { should be_directory }
end
end
# you can also use plain tests
describe file('/') do
it { should be_directory }
end

View file

@ -182,18 +182,18 @@ Test Summary: 0 successful, 0 failures, 0 skipped
inspec("exec " + File.join(profile_path, "controls-option-test") + " --no-create-lockfile --controls foo")
_(out.stdout).must_include "foo"
_(out.stdout).wont_include "bar"
_(out.stdout).wont_include "baz"
_(out.stdout).wont_include "only-describe"
_(stderr).must_equal ""
assert_exit_code 0, out
end
it "executes only specified controls when selecting the controls by literal names" do
it "executes only specified controls when selecting the controls by regex" do
inspec("exec " + File.join(profile_path, "controls-option-test") + " --no-create-lockfile --controls '/^11/'")
_(out.stdout).must_include "11_pass"
_(out.stdout).must_include "11_pass2"
_(out.stdout).wont_include "bar"
_(out.stdout).wont_include "baz"
_(out.stdout).wont_include "only-describe"
_(stderr).must_equal ""
assert_exit_code 0, out