Skip to content

Commit

Permalink
Fix unexpected keyword argument 'secret_path' in secrets.kv.v2 (#37626)
Browse files Browse the repository at this point in the history
* Fix unexpected keyword argument 'secret_path' in secrets.kv.v2

* Fix the input argument in secrets.kv.v1
  • Loading branch information
tungbq committed Feb 23, 2024
1 parent 2294a2f commit 3568b09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions airflow/providers/hashicorp/_internal_client/vault_client.py
Expand Up @@ -468,10 +468,10 @@ def create_or_update_secret(
mount_point, secret_path = self._parse_secret_path(secret_path)
if self.kv_engine_version == 1:
response = self.client.secrets.kv.v1.create_or_update_secret(
secret_path=secret_path, secret=secret, mount_point=mount_point, method=method
path=secret_path, secret=secret, mount_point=mount_point, method=method
)
else:
response = self.client.secrets.kv.v2.create_or_update_secret(
secret_path=secret_path, secret=secret, mount_point=mount_point, cas=cas
path=secret_path, secret=secret, mount_point=mount_point, cas=cas
)
return response
Expand Up @@ -1061,7 +1061,7 @@ def test_create_or_update_secret_v2(self, mock_hvac):
)
vault_client.create_or_update_secret(secret_path="path", secret={"key": "value"})
mock_client.secrets.kv.v2.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, cas=None
mount_point="secret", path="path", secret={"key": "value"}, cas=None
)

@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
Expand Down Expand Up @@ -1093,7 +1093,7 @@ def test_create_or_update_secret_v2_cas(self, mock_hvac):
)
vault_client.create_or_update_secret(secret_path="path", secret={"key": "value"}, cas=10)
mock_client.secrets.kv.v2.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, cas=10
mount_point="secret", path="path", secret={"key": "value"}, cas=10
)

@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
Expand All @@ -1111,7 +1111,7 @@ def test_create_or_update_secret_v1(self, mock_hvac):
)
vault_client.create_or_update_secret(secret_path="path", secret={"key": "value"})
mock_client.secrets.kv.v1.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, method=None
mount_point="secret", path="path", secret={"key": "value"}, method=None
)

@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
Expand Down Expand Up @@ -1145,7 +1145,7 @@ def test_create_or_update_secret_v1_post(self, mock_hvac):
)
vault_client.create_or_update_secret(secret_path="path", secret={"key": "value"}, method="post")
mock_client.secrets.kv.v1.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, method="post"
mount_point="secret", path="path", secret={"key": "value"}, method="post"
)

@mock.patch("airflow.providers.hashicorp._internal_client.vault_client.hvac")
Expand Down
6 changes: 3 additions & 3 deletions tests/providers/hashicorp/hooks/test_vault.py
Expand Up @@ -1208,7 +1208,7 @@ def test_create_or_update_secret_v2(self, mock_hvac, mock_get_connection):
test_hook = VaultHook(**kwargs)
test_hook.create_or_update_secret(secret_path="path", secret={"key": "value"})
mock_client.secrets.kv.v2.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, cas=None
mount_point="secret", path="path", secret={"key": "value"}, cas=None
)

@mock.patch("airflow.providers.hashicorp.hooks.vault.VaultHook.get_connection")
Expand All @@ -1227,7 +1227,7 @@ def test_create_or_update_secret_v2_cas(self, mock_hvac, mock_get_connection):
test_hook = VaultHook(**kwargs)
test_hook.create_or_update_secret(secret_path="path", secret={"key": "value"}, cas=10)
mock_client.secrets.kv.v2.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, cas=10
mount_point="secret", path="path", secret={"key": "value"}, cas=10
)

@pytest.mark.parametrize(
Expand All @@ -1253,7 +1253,7 @@ def test_create_or_update_secret_v1(self, mock_hvac, mock_get_connection, method
test_hook = VaultHook(**kwargs)
test_hook.create_or_update_secret(secret_path="path", secret={"key": "value"}, method=method)
mock_client.secrets.kv.v1.create_or_update_secret.assert_called_once_with(
mount_point="secret", secret_path="path", secret={"key": "value"}, method=expected_method
mount_point="secret", path="path", secret={"key": "value"}, method=expected_method
)


Expand Down

0 comments on commit 3568b09

Please sign in to comment.