Skip to content
This repository was archived by the owner on Apr 17, 2024. It is now read-only.

Commit 92d1a36

Browse files
morambrocopybara-github
authored andcommitted
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
1 parent e94e769 commit 92d1a36

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

python/tink/integration/hcvault/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@
2222
' install the `tink[hcvault]` extras?'
2323
) from import_error
2424

25-
create_aead = _hcvault_kms_aead.create_aead
25+
new_aead = _hcvault_kms_aead.new_aead

python/tink/integration/hcvault/_hcvault_kms_aead.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _get_endpoint_paths(key_path: str) -> Tuple[str, str]:
5555
return mount_and_key_name.groups()
5656

5757

58-
def create_aead(key_path: str, client: hvac.Client) -> aead.Aead:
58+
def new_aead(key_path: str, client: hvac.Client) -> aead.Aead:
5959
return _HcVaultKmsAead(client, key_path)
6060

6161

python/tink/integration/hcvault/_hcvault_kms_aead_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def tearDown(self):
121121

122122
def test_encrypt_decrypt(self):
123123
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
124-
vaultaead = hcvault.create_aead(_KEY_PATH, client)
124+
vaultaead = hcvault.new_aead(_KEY_PATH, client)
125125
plaintext = b'hello'
126126
associated_data = b'world'
127127
ciphertext = vaultaead.encrypt(plaintext, associated_data)
@@ -133,7 +133,7 @@ def test_encrypt_decrypt(self):
133133

134134
def test_invalid_context(self):
135135
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
136-
vaultaead = hcvault.create_aead(_KEY_PATH, client)
136+
vaultaead = hcvault.new_aead(_KEY_PATH, client)
137137

138138
plaintext = b'helloworld'
139139
ciphertext = vaultaead.encrypt(plaintext, b'')
@@ -144,7 +144,7 @@ def test_invalid_context(self):
144144
def test_encrypt_with_bad_uri(self):
145145
client = hvac.Client(url=_VAULT_URI, token=_TOKEN, verify=False)
146146
with self.assertRaises(tink.TinkError):
147-
hcvault.create_aead(_GCP_KEY_URI, client)
147+
hcvault.new_aead(_GCP_KEY_URI, client)
148148

149149
@parameterized.named_parameters([
150150
('simple', '/transit/keys/key-1', 'transit', 'key-1'),

python/tink/integration/hcvault/_hcvault_kms_integration_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def setUp(self):
5252
self.client = hvac.Client(url=_VAULT_ADDR, token=_VAULT_TOKEN, verify=False)
5353

5454
def test_encrypt_decrypt(self):
55-
vaultaead = hcvault.create_aead(_KEY_PATH, self.client)
55+
vaultaead = hcvault.new_aead(_KEY_PATH, self.client)
5656

5757
plaintext = b'hello'
5858
associated_data = b'world'
@@ -64,7 +64,7 @@ def test_encrypt_decrypt(self):
6464
self.assertEqual(plaintext, vaultaead.decrypt(ciphertext, b''))
6565

6666
def test_corrupted_ciphertext(self):
67-
vaultaead = hcvault.create_aead(_KEY_PATH, self.client)
67+
vaultaead = hcvault.new_aead(_KEY_PATH, self.client)
6868

6969
plaintext = b'helloworld'
7070
ciphertext = vaultaead.encrypt(plaintext, b'')
@@ -104,7 +104,7 @@ def test_corrupted_ciphertext(self):
104104
def test_encrypt_with_bad_client(self):
105105
with self.assertRaises(tink.TinkError):
106106
bad_client = hvac.Client(url=_VAULT_ADDR, token=_BAD_TOKEN, verify=False)
107-
vaultaead = hcvault.create_aead(_KEY_PATH, bad_client)
107+
vaultaead = hcvault.new_aead(_KEY_PATH, bad_client)
108108

109109
plaintext = b'hello'
110110
associated_data = b'world'

0 commit comments

Comments
 (0)