jscheffl commented on code in PR #59224:
URL: https://github.com/apache/airflow/pull/59224#discussion_r2645426708
##########
providers/hashicorp/tests/unit/hashicorp/secrets/test_vault.py:
##########
@@ -263,6 +313,52 @@ def test_get_variable_value_non_existent_key(self,
mock_hvac):
)
assert test_client.get_variable("hello") is None
+
@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
+ def test_get_variable_does_not_contain_value_key(self, mock_hvac):
+ """
+ Test that if the 'value' key is not present in Vault,
_VaultClient.get_variable
+ should log a warning and return None
+ """
+ mock_client = mock.MagicMock()
+ mock_hvac.Client.return_value = mock_client
+
+ kwargs = {
+ "variables_path": "variables",
+ "mount_point": "airflow",
+ "auth_type": "token",
+ "url": "http://127.0.0.1:8200",
+ "token": "s.7AU0I51yv1Q1lxOIg1F3ZRAS",
+ }
+ test_client = VaultBackend(**kwargs)
+ response = {"test_key": "data"}
+ test_client.vault_client.get_secret =
mock.MagicMock(return_value=response)
+
+ result = test_client.get_variable("hello")
+ assert result is None
Review Comment:
Oh, caplog is banned. Please use other means in capturing logs, not caplog.
--
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]