diff --git a/tests/manifests/__init__.py b/tests/manifests/__init__.py index 72c5ceb5..92de5819 100644 --- a/tests/manifests/__init__.py +++ b/tests/manifests/__init__.py @@ -6,6 +6,11 @@ import copy from typing import Any, Dict _raw_component_details = { + "initSecrets": { + "hyphened_name": "init-secrets", + "has_service_monitor": False, + "has_ingress": False, + }, "elementWeb": { "hyphened_name": "element-web", "has_service_monitor": False, diff --git a/tests/manifests/test_pod_securityContext.py b/tests/manifests/test_pod_securityContext.py index 9031a577..ba87652e 100644 --- a/tests/manifests/test_pod_securityContext.py +++ b/tests/manifests/test_pod_securityContext.py @@ -12,7 +12,7 @@ from .utils import iterate_component_workload_parts @pytest.mark.asyncio_cooperative async def test_sets_nonRoot_uids_gids_in_pod_securityContext_by_default(templates): for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert ( @@ -48,7 +48,7 @@ async def test_can_nuke_pod_securityContext_ids(component, values, make_template ) for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert ( @@ -65,7 +65,7 @@ async def test_can_nuke_pod_securityContext_ids(component, values, make_template @pytest.mark.asyncio_cooperative async def test_sets_seccompProfile_in_pod_securityContext_by_default(templates): for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert ( @@ -91,7 +91,7 @@ async def test_can_nuke_pod_securityContext_seccompProfile(component, values, ma ) for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert ( diff --git a/tests/manifests/test_secrets_consistency.py b/tests/manifests/test_secrets_consistency.py index e7269e23..4e8e11e8 100644 --- a/tests/manifests/test_secrets_consistency.py +++ b/tests/manifests/test_secrets_consistency.py @@ -70,7 +70,7 @@ async def test_secrets_consistency(templates): This test checks if each secret is correctly associated with its respective volume and container, ensuring that no inconsistencies or missing configurations exist. """ - workloads = [t for t in templates if t["kind"] in ("Deployment", "StatefulSet")] + workloads = [t for t in templates if t["kind"] in ("Deployment", "StatefulSet", "Job")] for template in workloads: # Gather all containers and initContainers from the template spec containers = template["spec"]["template"]["spec"].get("containers", []) + template["spec"]["template"][ diff --git a/tests/manifests/test_service_monitors.py b/tests/manifests/test_service_monitors.py index 137d7651..b0439dc8 100644 --- a/tests/manifests/test_service_monitors.py +++ b/tests/manifests/test_service_monitors.py @@ -24,7 +24,7 @@ def find_services_matching_selector(templates: Iterator[Any], selector: Dict[str def find_workload_ids_matching_selector(templates: Iterator[Any], selector: Dict[str, str]) -> list[str]: workload_ids = [] for template in templates: - if template["kind"] in ("Deployment", "StatefulSet") and selector_match( + if template["kind"] in ("Deployment", "StatefulSet", "Job") and selector_match( template["spec"]["template"]["metadata"]["labels"], selector ): workload_ids.append(f"{template['kind']}/{template['metadata']['name']}") @@ -99,7 +99,7 @@ async def test_service_monitored_as_appropriate(component, values: dict, make_te template["kind"] != "ServiceMonitor" ), f"{component} unexpectedly has a ServiceMonitor when all are turned off" if ( - template["kind"] in ["Deployment", "StatefulSet"] + template["kind"] in ["Deployment", "StatefulSet", "Job"] and template["metadata"]["labels"].get("servicemonitor", "some") != "none" ): workloads_to_cover.add(f"{template['kind']}/{template['metadata']['name']}") diff --git a/tests/manifests/test_serviceaccounts.py b/tests/manifests/test_serviceaccounts.py index a5647de1..4bbc76ff 100644 --- a/tests/manifests/test_serviceaccounts.py +++ b/tests/manifests/test_serviceaccounts.py @@ -14,7 +14,7 @@ from .utils import iterate_component_workload_parts @pytest.mark.asyncio_cooperative async def test_dont_automount_serviceaccount_tokens(templates): for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert not template["spec"]["template"]["spec"][ @@ -29,7 +29,7 @@ async def test_uses_serviceaccount_named_as_per_pod_controller_by_default(templa serviceaccount_names = set() covered_serviceaccount_names = set() for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: workloads_by_id[f"{template['kind']}/{template['metadata']['name']}"] = template elif template["kind"] == "ServiceAccount": serviceaccount_names.add(template["metadata"]["name"]) @@ -67,7 +67,7 @@ async def test_uses_serviceaccount_named_as_values_if_specified(component, value workloads_by_id = {} serviceaccount_names = [] for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: workloads_by_id[f"{template['kind']}/{template['metadata']['name']}"] = template elif template["kind"] == "ServiceAccount": serviceaccount_names.append(template["metadata"]["name"]) @@ -104,7 +104,7 @@ async def test_does_not_create_serviceaccounts_if_configured_not_to(component, v serviceaccount_names = set() covered_serviceaccount_names = set() for template in await make_templates(sub_component_values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id_suffix = f" (for {sub_component})" if sub_component != "" else "" workloads_by_id[f"{template['kind']}/{template['metadata']['name']}{id_suffix}"] = template elif template["kind"] == "ServiceAccount": diff --git a/tests/manifests/test_tolerations.py b/tests/manifests/test_tolerations.py index 5c9a2ee3..04bc8daa 100644 --- a/tests/manifests/test_tolerations.py +++ b/tests/manifests/test_tolerations.py @@ -26,7 +26,7 @@ global_toleration = { @pytest.mark.asyncio_cooperative async def test_no_tolerations_by_default(templates): for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" assert ( @@ -42,7 +42,7 @@ async def test_all_components_and_sub_components_render_tolerations(component, v ) for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" pod_spec = template["spec"]["template"]["spec"] @@ -57,7 +57,7 @@ async def test_global_tolerations_render(values, make_templates): values.setdefault("tolerations", []).append(global_toleration) for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" pod_spec = template["spec"]["template"]["spec"] @@ -78,7 +78,7 @@ async def test_merges_global_and_specific_tolerations(component, values, make_te values.get("tolerations").append(global_toleration) for template in await make_templates(values): - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: id = f"{template['kind']}/{template['metadata']['name']}" pod_spec = template["spec"]["template"]["spec"] diff --git a/tests/manifests/test_volumes_mounts.py b/tests/manifests/test_volumes_mounts.py index c555e01c..fc437dd1 100644 --- a/tests/manifests/test_volumes_mounts.py +++ b/tests/manifests/test_volumes_mounts.py @@ -13,7 +13,7 @@ async def test_volumes_mounts_exists(templates): configmaps_names = [t["metadata"]["name"] for t in templates if t["kind"] == "ConfigMap"] secrets_names = [t["metadata"]["name"] for t in templates if t["kind"] == "Secret"] for template in templates: - if template["kind"] in ["Deployment", "StatefulSet"]: + if template["kind"] in ["Deployment", "StatefulSet", "Job"]: volumes_names = [] for volume in template["spec"]["template"]["spec"].get("volumes", []): volumes_names.append(volume["name"])