mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-13 00:05:04 +00:00
feat(checks): Exclude checks with -e/--exclude-checks
* feat(checks): Select checks to run * feat(checks): Include tests * feat(checks): Exclude checks with -e * fix(checks): Include missing path * fix(checks): Include comments
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
|
||||
from lib.check.check import parse_checks_from_file
|
||||
from lib.check.check import exclude_checks_to_run, parse_checks_from_file
|
||||
|
||||
|
||||
class Test_Check:
|
||||
@@ -15,15 +15,13 @@ class Test_Check:
|
||||
# for test in test_cases:
|
||||
# assert importlib.import_module(test["input"]).__name__ == test["expected"]
|
||||
|
||||
def test_parse_checks_from_file(checks_file):
|
||||
def test_parse_checks_from_file(self):
|
||||
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",
|
||||
@@ -37,3 +35,27 @@ class Test_Check:
|
||||
]
|
||||
for test in test_cases:
|
||||
assert parse_checks_from_file(test["input"]) == test["expected"]
|
||||
|
||||
def test_exclude_checks_to_run(self):
|
||||
test_cases = [
|
||||
{
|
||||
"input": {
|
||||
"check_list": {"check12", "check11", "extra72", "check13"},
|
||||
"excluded_checks": {"check12", "check13"},
|
||||
},
|
||||
"expected": {"check11", "extra72"},
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"check_list": {"check112", "check11", "extra72", "check13"},
|
||||
"excluded_checks": {"check12", "check13", "check14"},
|
||||
},
|
||||
"expected": {"check112", "check11", "extra72"},
|
||||
},
|
||||
]
|
||||
for test in test_cases:
|
||||
check_list = test["input"]["check_list"]
|
||||
excluded_checks = test["input"]["excluded_checks"]
|
||||
assert (
|
||||
exclude_checks_to_run(check_list, excluded_checks) == test["expected"]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user