ashb commented on a change in pull request #15795:
URL: https://github.com/apache/airflow/pull/15795#discussion_r636862403
##########
File path: airflow/api_connexion/endpoints/connection_endpoint.py
##########
@@ -129,3 +133,21 @@ def post_connection(session):
session.commit()
return connection_schema.dump(connection)
raise AlreadyExists(detail=f"Connection already exist. ID: {conn_id}")
+
+
[email protected]_access([(permissions.ACTION_CAN_CREATE,
permissions.RESOURCE_CONNECTION)])
+def test_connection():
+ """Test a connection"""
+ body = request.json
+ try:
+ data = connection_schema.load(body)
+ dummy_conn_id = get_random_string()
+ data['conn_id'] = dummy_conn_id
+ conn = Connection(**data)
+ conn_env_var = f'AIRFLOW_CONN_{dummy_conn_id.upper()}'
Review comment:
```suggestion
from airflow.secrets.environment_variables import CONN_ENV_PREFIX
conn_env_var = f'{CONN_ENV_PREFIX}{dummy_conn_id.upper()}'
```
(feel free to move the import somewhere more appropriate.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]