choo121600 commented on code in PR #59643:
URL: https://github.com/apache/airflow/pull/59643#discussion_r2702177199


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py:
##########
@@ -992,14 +992,85 @@ def test_connection_env_is_cleaned_after_run(self, 
test_client, body):
             {"connection_id": TEST_CONN_ID, "conn_type": "ftp"},
         ],
     )
-    def test_should_respond_403_by_default(self, test_client, body):
+    
@mock.patch("airflow.api_fastapi.core_api.routes.public.connections.conf.get")
+    def test_should_respond_403_by_default(self, mock_conf_get, test_client, 
body):
+        mock_conf_get.return_value = "Disabled"
         response = test_client.post("/connections/test", json=body)
         assert response.status_code == 403
         assert response.json() == {
             "detail": "Testing connections is disabled in Airflow 
configuration. "
             "Contact your deployment admin to enable it."
         }
 
+    @mock.patch.dict(os.environ, {"AIRFLOW__CORE__TEST_CONNECTION": "Enabled"})
+    def test_should_merge_password_with_existing_connection(self, test_client, 
session):
+        connection = Connection(
+            conn_id=TEST_CONN_ID,
+            conn_type="sqlite",
+            password="existing_password",
+        )
+        session.add(connection)
+        session.commit()
+
+        body = {
+            "connection_id": TEST_CONN_ID,
+            "conn_type": "sqlite",
+            "password": "***",
+        }
+        response = test_client.post("/connections/test", json=body)
+        assert response.status_code == 200
+        assert response.json()["status"] is True

Review Comment:
   I would also add an assertion to check wasn't mutated into db, and that no 
other connection record was created



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