Aakcht commented on code in PR #31865:
URL: https://github.com/apache/airflow/pull/31865#discussion_r1238081019
##########
tests/charts/security/test_security_context.py:
##########
@@ -210,6 +210,36 @@ def test_gitsync_sidecar_and_init_container(self):
docs[index],
)
+ # Test securityContexts for main containers
+ def test_global_security_context(self):
+ ctx_value_pod = {"runAsUser": 7000}
+ ctx_value_container = {"allowPrivilegeEscalation": False}
+ docs = render_chart(
+ values={"securityContexts": {"containers": ctx_value_container,
"pod": ctx_value_pod}},
+ show_only=[
+ "templates/flower/flower-deployment.yaml",
+ "templates/scheduler/scheduler-deployment.yaml",
+ "templates/webserver/webserver-deployment.yaml",
+ "templates/workers/worker-deployment.yaml",
+ "templates/jobs/create-user-job.yaml",
+ "templates/jobs/migrate-database-job.yaml",
+ "templates/triggerer/triggerer-deployment.yaml",
+ "templates/statsd/statsd-deployment.yaml",
+ "templates/redis/redis-statefulset.yaml",
+ ],
+ )
+
+ for index in range(len(docs) - 2):
+ assert ctx_value_container == jmespath.search(
+ "spec.template.spec.containers[0].securityContext", docs[index]
+ )
+ assert ctx_value_pod ==
jmespath.search("spec.template.spec.securityContext", docs[index])
+ for index in range(len(docs) - 2, len(docs)):
+ assert ctx_value_container != jmespath.search(
+ "spec.template.spec.containers[0].securityContext", docs[index]
+ )
+ assert ctx_value_pod !=
jmespath.search("spec.template.spec.securityContext", docs[index])
Review Comment:
Added the check that it's by default `allowPrivilegesEscalation: false,
capabilities.drop: [ALL]`. As for providing values, there are already tests
that check this case, for example
https://github.com/apache/airflow/blob/main/tests/charts/security/test_security_context.py#L50
or
https://github.com/apache/airflow/blob/main/tests/charts/security/test_security_context.py#L223
.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]