From 92d1a369540546c349599c43f3a1490185568c5e Mon Sep 17 00:00:00 2001 From: ambrosin Date: Wed, 31 Jan 2024 01:21:55 -0800 Subject: [PATCH] Rename `create_aead` to `new_aead` in Python HashiCorp Vault KMS integration This makes it more consistent with the tink-go-hcvault implementation [1]. [1] https://github.com/tink-crypto/tink-go-hcvault/blob/f6867b9cff6fd8f6f91a88110628e8d6b7ba7e7b/integration/hcvault/hcvault_aead.go#L80 PiperOrigin-RevId: 602971968 --- python/tink/integration/hcvault/__init__.py | 2 +- python/tink/integration/hcvault/_hcvault_kms_aead.py | 2 +- python/tink/integration/hcvault/_hcvault_kms_aead_test.py | 6 +++--- .../integration/hcvault/_hcvault_kms_integration_test.py | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python/tink/integration/hcvault/__init__.py b/python/tink/integration/hcvault/__init__.py index e95184d322..4133984b90 100644 --- a/python/tink/integration/hcvault/__init__.py +++ b/python/tink/integration/hcvault/__init__.py @@ -22,4 +22,4 @@ ' install the `tink[hcvault]` extras?' ) from import_error -create_aead = _hcvault_kms_aead.create_aead +new_aead = _hcvault_kms_aead.new_aead diff --git a/python/tink/integration/hcvault/_hcvault_kms_aead.py b/python/tink/integration/hcvault/_hcvault_kms_aead.py index bdb074f130..44a50453fd 100644 --- a/python/tink/integration/hcvault/_hcvault_kms_aead.py +++ b/python/tink/integration/hcvault/_hcvault_kms_aead.py @@ -55,7 +55,7 @@ def _get_endpoint_paths(key_path: str) -> Tuple[str, str]: return mount_and_key_name.groups() -def create_aead(key_path: str, client: hvac.Client) -> aead.Aead: +def new_aead(key_path: str, client: hvac.Client) -> aead.Aead: return _HcVaultKmsAead(client, key_path) diff --git a/python/tink/integration/hcvault/_hcvault_kms_aead_test.py b/python/tink/integration/hcvault/_hcvault_kms_aead_test.py index 3e2a217547..60bb220d3c 100644 --- a/python/tink/integration/hcvault/_hcvault_kms_aead_test.py +++ b/python/tink/integration/hcvault/_hcvault_kms_aead_test.py @@ -121,7 +121,7 @@ def tearDown(self): def test_encrypt_decrypt(self): client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False) - vaultaead = hcvault.create_aead(_KEY_PATH, client) + vaultaead = hcvault.new_aead(_KEY_PATH, client) plaintext = b'hello' associated_data = b'world' ciphertext = vaultaead.encrypt(plaintext, associated_data) @@ -133,7 +133,7 @@ def test_encrypt_decrypt(self): def test_invalid_context(self): client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False) - vaultaead = hcvault.create_aead(_KEY_PATH, client) + vaultaead = hcvault.new_aead(_KEY_PATH, client) plaintext = b'helloworld' ciphertext = vaultaead.encrypt(plaintext, b'') @@ -144,7 +144,7 @@ def test_invalid_context(self): def test_encrypt_with_bad_uri(self): client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False) with self.assertRaises(tink.TinkError): - hcvault.create_aead(_GCP_KEY_URI, client) + hcvault.new_aead(_GCP_KEY_URI, client) @parameterized.named_parameters([ ('simple', '/transit/keys/key-1', 'transit', 'key-1'), diff --git a/python/tink/integration/hcvault/_hcvault_kms_integration_test.py b/python/tink/integration/hcvault/_hcvault_kms_integration_test.py index f167c4fd40..8337c00e81 100644 --- a/python/tink/integration/hcvault/_hcvault_kms_integration_test.py +++ b/python/tink/integration/hcvault/_hcvault_kms_integration_test.py @@ -52,7 +52,7 @@ def setUp(self): self.client = hvac.Client(url=_VAULT_ADDR, token=_VAULT_TOKEN, verify=False) def test_encrypt_decrypt(self): - vaultaead = hcvault.create_aead(_KEY_PATH, self.client) + vaultaead = hcvault.new_aead(_KEY_PATH, self.client) plaintext = b'hello' associated_data = b'world' @@ -64,7 +64,7 @@ def test_encrypt_decrypt(self): self.assertEqual(plaintext, vaultaead.decrypt(ciphertext, b'')) def test_corrupted_ciphertext(self): - vaultaead = hcvault.create_aead(_KEY_PATH, self.client) + vaultaead = hcvault.new_aead(_KEY_PATH, self.client) plaintext = b'helloworld' ciphertext = vaultaead.encrypt(plaintext, b'') @@ -104,7 +104,7 @@ def test_corrupted_ciphertext(self): def test_encrypt_with_bad_client(self): with self.assertRaises(tink.TinkError): bad_client = hvac.Client(url=_VAULT_ADDR, token=_BAD_TOKEN, verify=False) - vaultaead = hcvault.create_aead(_KEY_PATH, bad_client) + vaultaead = hcvault.new_aead(_KEY_PATH, bad_client) plaintext = b'hello' associated_data = b'world'