msumit commented on a change in pull request #15795:
URL: https://github.com/apache/airflow/pull/15795#discussion_r636704895
##########
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()}'
+ os.environ[conn_env_var] = conn.get_uri()
Review comment:
Yes, but some hooks tried to get the conn object from their __init__,
and as we are not storing anything in DB, they fail. Setting it in env let them
use the connection.
--
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]