From b180914889b439dea7e2f2773f17e743b738fd15 Mon Sep 17 00:00:00 2001 From: Vasu1105 Date: Fri, 19 Mar 2021 12:37:54 +0530 Subject: [PATCH] Updated test for --controls option Signed-off-by: Vasu1105 --- .../controls-option-test/controls/example.rb | 41 +------------------ test/functional/inspec_exec_test.rb | 6 +-- 2 files changed, 4 insertions(+), 43 deletions(-) diff --git a/test/fixtures/profiles/controls-option-test/controls/example.rb b/test/fixtures/profiles/controls-option-test/controls/example.rb index 948b97d6c..69370de1f 100644 --- a/test/fixtures/profiles/controls-option-test/controls/example.rb +++ b/test/fixtures/profiles/controls-option-test/controls/example.rb @@ -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 \ No newline at end of file diff --git a/test/functional/inspec_exec_test.rb b/test/functional/inspec_exec_test.rb index 8816c6a23..9c53a6ac5 100644 --- a/test/functional/inspec_exec_test.rb +++ b/test/functional/inspec_exec_test.rb @@ -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