def test_runner_skip_graph_when_no_plan_exists(self): # given tf_file_path = Path(__file__).parent / "resource/example/example.tf" # when report = Runner().run( root_folder=None, files=[str(tf_file_path)], external_checks_dir=None, runner_filter=RunnerFilter(framework="terraform_plan"), ) # then summary = report.get_summary() self.assertEqual(report.get_summary()["failed"], 0) self.assertEqual(report.get_summary()["passed"], 0) self.assertEqual(report.get_summary()["skipped"], 0) self.assertEqual(report.get_summary()["parsing_errors"], 0) self.assertEqual(report.get_summary()["resource_count"], 0)
def test_runner_with_resource_reference(self): current_dir = os.path.dirname(os.path.realpath(__file__)) valid_plan_path = current_dir + "/resources/plan_with_resource_reference/tfplan.json" allowed_checks = ["CKV_AWS_84"] report = Runner().run( root_folder=None, files=[valid_plan_path], external_checks_dir=None, runner_filter=RunnerFilter(framework="all", checks=allowed_checks), ) report_json = report.get_json() self.assertIsInstance(report_json, str) self.assertIsNotNone(report_json) self.assertIsNotNone(report.get_test_suites()) self.assertEqual(report.get_exit_code(soft_fail=False), 0) self.assertEqual(report.get_exit_code(soft_fail=True), 0) self.assertEqual(report.get_summary()["failed"], 0) self.assertEqual(report.get_summary()["passed"], 1)
def test_runner_with_resource_reference_graph_check(self): # given valid_plan_path = Path( __file__ ).parent / "resources/plan_with_resource_reference/tfplan_graph.json" allowed_checks = ["CKV2_AWS_6"] # when report = Runner().run( root_folder=None, files=[str(valid_plan_path)], external_checks_dir=None, runner_filter=RunnerFilter(framework=["terraform_plan"], checks=allowed_checks), ) # then summary = report.get_summary() self.assertEqual(summary["failed"], 0) self.assertEqual(summary["passed"], 1)