Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions newsfragments/625.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Check automount service account policy against Job in tests.
4 changes: 4 additions & 0 deletions tests/manifests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class DeployableDetails(abc.ABC):
has_db: bool = field(default=False, hash=False)
has_image: bool = field(default=None, hash=False) # type: ignore[assignment]
has_ingress: bool = field(default=True, hash=False)
has_automount_service_account_token: bool = field(default=False, hash=False)
has_workloads: bool = field(default=True, hash=False)
has_replicas: bool = field(default=None, hash=False) # type: ignore[assignment]
has_service_monitor: bool = field(default=None, hash=False) # type: ignore[assignment]
Expand Down Expand Up @@ -410,6 +411,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
},
has_image=False,
has_ingress=False,
has_automount_service_account_token=True,
has_replicas=False,
has_service_monitor=False,
has_topology_spread_constraints=False,
Expand All @@ -429,6 +431,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
},
has_image=False,
has_ingress=False,
has_automount_service_account_token=True,
has_replicas=False,
has_service_monitor=False,
has_topology_spread_constraints=False,
Expand Down Expand Up @@ -531,6 +534,7 @@ def make_synapse_worker_sub_component(worker_name: str, worker_type: str) -> Sub
PropertyType.StartupProbe: ValuesFilePath.not_supported(),
},
has_ingress=False,
has_automount_service_account_token=True,
has_replicas=False,
has_service_monitor=False,
has_topology_spread_constraints=False,
Expand Down
12 changes: 7 additions & 5 deletions tests/manifests/test_serviceaccounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@
import pytest

from . import DeployableDetails, PropertyType, all_deployables_details, values_files_to_test
from .utils import iterate_deployables_workload_parts, template_id
from .utils import iterate_deployables_workload_parts, template_id, template_to_deployable_details


@pytest.mark.parametrize("values_file", values_files_to_test)
@pytest.mark.asyncio_cooperative
async def test_dont_automount_serviceaccount_tokens(templates):
async def test_automount_serviceaccount_tokens_as_appropriate(templates):
for template in templates:
if template["kind"] in ["Deployment", "StatefulSet"]:
assert not template["spec"]["template"]["spec"]["automountServiceAccountToken"], (
f"ServiceAccount token automounted for {template_id(template)}"
deployable_details = template_to_deployable_details(template)
if template["kind"] in ["Deployment", "StatefulSet", "Job"]:
assert (
deployable_details.has_automount_service_account_token
== template["spec"]["template"]["spec"]["automountServiceAccountToken"]
)


Expand Down
Loading