forked from bridgecrewio/checkov
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_checkov_json_report.py
30 lines (21 loc) · 978 Bytes
/
test_checkov_json_report.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import unittest
import json
import os
current_dir = os.path.dirname(os.path.realpath(__file__))
class TestCheckovJsonReport(unittest.TestCase):
def test_terragoat_report(self):
report_path = current_dir + "/../checkov_report_terragoat.json"
self.validate_report(report_path)
def test_cfngoat_report(self):
report_path = current_dir + "/../checkov_report_cfngoat.json"
self.validate_report(report_path)
def test_k8goat_report(self):
report_path = current_dir + "/../checkov_report_kubernetes-goat.json"
self.validate_report(report_path)
def validate_report(self, report_path):
with open(report_path) as json_file:
data = json.load(json_file)
self.assertEqual(data["summary"]["parsing_errors"], 0, "expecting 0 parsing errors")
self.assertGreater(data["summary"]["failed"], 1, "expecting more then 1 failed checks")
if __name__ == '__main__':
unittest.main()