feat(checks): Select checks to run from provider using -C/--checks-file (#1200)

This commit is contained in:
Pepe Fagoaga
2022-06-16 12:49:55 +02:00
committed by GitHub
parent 162852634e
commit 9d5e43e6a2
8 changed files with 103 additions and 21 deletions

39
lib/check/check_test.py Normal file
View File

@@ -0,0 +1,39 @@
import os
from lib.check.check import parse_checks_from_file
class Test_Check:
# def test_import_check(self):
# test_cases = [
# {
# "name": "Test valid check path",
# "input": "providers.aws.services.iam.iam_disable_30_days_credentials.iam_disable_30_days_credentials",
# "expected": "providers.aws.services.iam.iam_disable_30_days_credentials.iam_disable_30_days_credentials",
# }
# ]
# for test in test_cases:
# assert importlib.import_module(test["input"]).__name__ == test["expected"]
def test_parse_checks_from_file(checks_file):
test_cases = [
{
"name": "Test valid check path",
"input": f"{os.path.dirname(os.path.realpath(__file__))}/fixtures/checklistA.txt",
"expected": {"check12", "check11", "extra72", "check13"},
},
{
"name": "Test valid check path",
"input": f"{os.path.dirname(os.path.realpath(__file__))}/fixtures/checklistB.txt",
"expected": {
"extra72",
"check13",
"check11",
"check12",
"check56",
"check2423",
},
},
]
for test in test_cases:
assert parse_checks_from_file(test["input"]) == test["expected"]