Updated test so that can run in the test enviornment

Signed-off-by: Vasu1105 <vasundhara.jagdale@chef.io>
This commit is contained in:
Vasu1105 2021-03-25 19:15:50 +05:30
parent 7c25a2b5df
commit a0d669a0f0
2 changed files with 3 additions and 8 deletions

View file

@ -1,5 +1,5 @@
control 'exception_catcher_test' do
describe shadow.users('root') do
describe shadow('/tmp/no-file').users('root') do
its(:passwords) { should_not include('*') }
end
end

View file

@ -10,11 +10,6 @@ describe "filtertable functional tests" do
run_inspec_process(cmd, run_opts)
end
def run_result_for_controls_without_sudo(controls)
cmd = "exec " + ft_profile_path + " --controls " + controls.join(" ") + " --no-sudo"
run_inspec_process(cmd, run_opts)
end
def failed_control_test_outcomes(run_result)
failed_controls = @json["profiles"][0]["controls"].select { |ctl| ctl["results"][0]["status"] == "failed" }
@ -144,9 +139,9 @@ describe "filtertable functional tests" do
describe "if control fails" do
it "should show the exact error message" do
controls = ["exception_catcher_test"]
run_result = run_result_for_controls_without_sudo(controls)
run_result = run_result_for_controls(controls)
outcome_hash = skipped_control_test_outcomes(run_result)
_(outcome_hash["exception_catcher_test"]).must_include "Can't read file: \/etc\/shadow"
_(outcome_hash["exception_catcher_test"]).must_include "Can't find file: \/tmp\/no-file"
assert_exit_code 101, run_result
end
end