jason810496 commented on code in PR #45931:
URL: https://github.com/apache/airflow/pull/45931#discussion_r2251688093


##########
airflow-core/tests/unit/always/test_secrets.py:
##########
@@ -119,6 +120,40 @@ def test_backend_fallback_to_env_var(self, 
mock_get_connection):
 
         assert conn.get_uri() == "mysql://airflow:airflow@host:5432/airflow"
 
+    @conf_vars(
+        {
+            (
+                "secrets",
+                "backend",
+            ): 
"airflow.providers.amazon.aws.secrets.systems_manager.SystemsManagerParameterStoreBackend",
+            ("secrets", "backend_kwargs"): '{"connections_prefix": "/airflow", 
"profile_name": null}',
+            ("secrets", "backends_order"): 
"custom,environment_variable,metastore",
+        }
+    )
+    def test_backends_order(self):
+        backends = ensure_secrets_loaded()
+        backend_classes = [backend.__class__.__name__ for backend in backends]
+        assert backend_classes == [
+            "SystemsManagerParameterStoreBackend",
+            "EnvironmentVariablesBackend",
+            "MetastoreBackend",
+        ]
+
+    @conf_vars({("secrets", "backends_order"): "custom,metastore"})
+    def test_backends_order_no_environment_variable_backend(self):
+        with pytest.raises(AirflowConfigException):
+            ensure_secrets_loaded()
+
+    @conf_vars({("secrets", "backends_order"): "environment_variable"})
+    def test_backends_order_no_metastore_backend(self):
+        with pytest.raises(AirflowConfigException):
+            ensure_secrets_loaded()
+
+    @conf_vars({("secrets", "backends_order"): 
"metastore,environment_variable,unsupported"})
+    def test_backends_order_unsupported(self):
+        with pytest.raises(AirflowConfigException):
+            ensure_secrets_loaded()

Review Comment:
   Small nits, no strong opnion.
   Maybe we can combine the test cases with `pytest.mark.parameterize`.



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/config.py:
##########
@@ -155,3 +155,36 @@ def get_config_value(
 
     config = Config(sections=[ConfigSection(name=section, 
options=[ConfigOption(key=option, value=value)])])
     return _response_based_on_accept(accept, config)
+
+
+@config_router.get(
+    "/backends_order",
+    responses={
+        **create_openapi_http_exception_doc(
+            [
+                status.HTTP_404_NOT_FOUND,
+                status.HTTP_406_NOT_ACCEPTABLE,
+            ]
+        ),
+        status.HTTP_200_OK: {
+            "description": "Successful Response",
+            "content": text_example_response_for_get_config_value,
+        },
+    },
+    response_model=Config,
+    dependencies=[Depends(requires_access_configuration("GET"))],
+)
+def get_backends_order_value(

Review Comment:
   It seems we can reuse with `get_config_value` route.
   Or if the `get_backends_order_value` is necessary, it will be better to move 
the route under `airflow-core/src/airflow/api_fastapi/core_api/routes/ui`



##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/config.py:
##########
@@ -155,3 +155,36 @@ def get_config_value(
 
     config = Config(sections=[ConfigSection(name=section, 
options=[ConfigOption(key=option, value=value)])])
     return _response_based_on_accept(accept, config)
+
+
+@config_router.get(
+    "/backends_order",
+    responses={
+        **create_openapi_http_exception_doc(
+            [
+                status.HTTP_404_NOT_FOUND,
+                status.HTTP_406_NOT_ACCEPTABLE,
+            ]
+        ),
+        status.HTTP_200_OK: {
+            "description": "Successful Response",
+            "content": text_example_response_for_get_config_value,
+        },
+    },
+    response_model=Config,
+    dependencies=[Depends(requires_access_configuration("GET"))],
+)
+def get_backends_order_value(

Review Comment:
   May I ask why do we need "backends_order" specific new endpoint?



-- 
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]

Reply via email to