choo121600 commented on code in PR #59643:
URL: https://github.com/apache/airflow/pull/59643#discussion_r2702174714
##########
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": "***",
+ }
Review Comment:
I added a mock_test_connection function that captures the actual password
used during the test.
we assert that captured_password["value"] == "existing_password" to verify
the existing password is used instead of "***"
--
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]