/ test / handler / test_checkov_handler.vader
test_checkov_handler.vader
 1  Before:
 2    runtime ale_linters/terraform/checkov.vim
 3    call ale#test#SetFilename('main.tf')
 4  
 5  After:
 6    call ale#linter#Reset()
 7  
 8  Execute(The JSON output of checkov should be handled correctly):
 9    AssertEqual
10    \ [
11    \   {
12    \         'filename': '/main.tf',
13    \         'lnum': 22,
14    \         'end_lnum': 27,
15    \         'text': 'Enable VPC Flow Logs and Intranode Visibility [CKV_GCP_61]',
16    \         'detail': "CKV_GCP_61: Enable VPC Flow Logs and Intranode Visibility\n" .
17    \                   'For more information, see: https://docs.bridgecrew.io/docs/enable-vpc-flow-logs-and-intranode-visibility',
18    \         'type': 'W',
19    \   }
20    \ ],
21    \ ale_linters#terraform#checkov#Handle(bufnr(''), [
22    \'{',
23    \'    "check_type": "terraform",',
24    \'    "results": {',
25    \'        "failed_checks": [',
26    \'            {',
27    \'                "check_id": "CKV_GCP_61",',
28    \'                "bc_check_id": "BC_GCP_KUBERNETES_18",',
29    \'                "check_name": "Enable VPC Flow Logs and Intranode Visibility",',
30    \'                "check_result": {',
31    \'                    "result": "FAILED",',
32    \'                    "evaluated_keys": [',
33    \'                        "enable_intranode_visibility"',
34    \'                    ]',
35    \'                },',
36    \'                "file_path": "/main.tf",',
37    \'                "repo_file_path": "/main.tf",',
38    \'                "file_line_range": [',
39    \'                    22,',
40    \'                    27',
41    \'                ],',
42    \'                "resource": "google_container_cluster.cluster-name",',
43    \'                "evaluations": null,',
44    \'                "check_class": "checkov.terraform.checks.resource.gcp.GKEEnableVPCFlowLogs",',
45    \'                "entity_tags": null,',
46    \'                "resource_address": null,',
47    \'                "guideline": "https://docs.bridgecrew.io/docs/enable-vpc-flow-logs-and-intranode-visibility"',
48    \'            }',
49    \'        ]',
50    \'    }',
51    \'}'
52    \ ])
53  
54  Execute(Handle output for no findings correctly):
55    AssertEqual
56    \ [],
57    \ ale_linters#terraform#checkov#Handle(bufnr(''), [
58    \'{',
59    \'    "passed": 0,',
60    \'    "failed": 0,',
61    \'    "skipped": 0,',
62    \'    "parsing_errors": 0,',
63    \'    "resource_count": 0,',
64    \'    "checkov_version": "2.0.632"',
65    \'}'
66    \])