Skip to content

Commit

Permalink
remove obsolete kubescape unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Gierlinger committed Nov 4, 2023
1 parent d26405f commit 9a293d3
Showing 1 changed file with 0 additions and 50 deletions.
50 changes: 0 additions & 50 deletions tests/evaluation/scanner/test_kubescape.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from kalm_benchmark.evaluation.scanner.kubescape import (
_consolidate_objects,
_get_check_path,
_parse_api_object,
)
from kalm_benchmark.manifest_generator.constants import CheckStatus
Expand Down Expand Up @@ -335,52 +334,3 @@ def test_rbac_with_no_check_merges_all_fields(self):
}

assert res == expect


class TestCheckPathExtraction:
def test_only_failed_paths(self):
failed_paths = ["spec.template.metadata.labels"]

res = _get_check_path(failed_paths)
assert res == ".metadata.labels"

def test_multiple_paths_are_concatinated(self):
paths = [
"relatedObjects[1].rules[2].resources[0]",
"relatedObjects[1].rules[2].verbs[2]",
"relatedObjects[0].roleRef.name",
]
res = _get_check_path(paths)
assert "|" in res
resulting_paths = res.split("|")
# note: implicit deduplication does not preserve order, so a set comparison will be done instead
expect = set(
[
".relatedObjects[].rules[].resources[]",
".relatedObjects[].rules[].verbs[]",
".relatedObjects[].roleRef.name",
]
)
assert len(set(resulting_paths) - expect) == 0

def test_results_are_deduplicated(self):
failed_paths = ["spec.template.metadata.labels", "metadata.labels"]
res = _get_check_path(failed_paths)
assert res == ".metadata.labels"

def test_only_fix_paths(self):
paths = [
"spec.template.spec.containers[0].resources.limits.memory",
"spec.template.spec.containers[0].resources.requests.memory",
]
fix_paths = [{"path": p, "value": "-"} for p in paths]
res = _get_check_path(None, fix_paths)
assert "|" in res
resulting_paths = res.split("|")
expected_paths = set(
[".spec.containers[].resources.limits.memory", ".spec.containers[].resources.requests.memory"]
)
assert len(set(resulting_paths) - expected_paths) == 0

def test_no_paths_result_in_none(self):
assert _get_check_path(None, None) is None

0 comments on commit 9a293d3

Please sign in to comment.