kaxil commented on a change in pull request #7741: [AIRFLOW-7076] Add support for HashiCorp Vault as Secrets Backend URL: https://github.com/apache/airflow/pull/7741#discussion_r394664957
########## File path: tests/providers/hashicorp/secrets/test_vault.py ########## @@ -0,0 +1,137 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from unittest import TestCase, mock + +from hvac.exceptions import VaultError + +from airflow.providers.hashicorp.secrets.vault import VaultSecrets + + +class TestVaultSecrets(TestCase): + + @mock.patch("airflow.providers.hashicorp.secrets.vault.hvac") + def test_get_conn_uri(self, mock_hvac): + mock_client = mock.MagicMock() + mock_hvac.Client.return_value = mock_client + mock_client.secrets.kv.v2.read_secret_version.return_value = { + 'request_id': '94011e25-f8dc-ec29-221b-1f9c1d9ad2ae', + 'lease_id': '', + 'renewable': False, + 'lease_duration': 0, + 'data': { + 'data': {'test_postgres': 'postgresql://airflow:airflow@host:5432/airflow'}, Review comment: So all the connections would live in a single path `airflow/connections` and it accepts a key_value store. Key I think should be **conn_id**. Storing them as following: ``` vault kv put airflow/connections conn_type=postgresql user=airflow password=airflow host=host port=5432 schema=airflow ``` would create separate keys: ``` ❯ vault kv put airflow/connections conn_type=mysql user=airflow password=airflow host=host port=5432 schema=airflow Key Value --- ----- created_time 2020-03-18T22:00:51.665274Z deletion_time n/a destroyed false version 2 ❯ vault kv get airflow/connections ====== Metadata ====== Key Value --- ----- created_time 2020-03-18T22:00:51.665274Z deletion_time n/a destroyed false version 2 ====== Data ====== Key Value --- ----- conn_type mysql host host password airflow port 5432 schema airflow user airflow ``` which doesn't make sense as they are not linked to each other. I think what we have currently is fine ---------------------------------------------------------------- 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] With regards, Apache Git Services
