Merge "Fixed encryption type methods to comply with documentation"

This commit is contained in:
Zuul 2024-12-12 12:53:53 +00:00 committed by Gerrit Code Review
commit 422131d952
3 changed files with 10 additions and 7 deletions

View File

@ -143,6 +143,7 @@ class VolumeTypesTest(base.BaseVolumeAdminTest):
# Get encryption type
encrypt_type_id = encryption_type['volume_type_id']
encryption_id = encryption_type['encryption_id']
fetched_encryption_type = (
self.admin_encryption_types_client.show_encryption_type(
encrypt_type_id))
@ -157,7 +158,7 @@ class VolumeTypesTest(base.BaseVolumeAdminTest):
'cipher': 'aes-xts-plain64',
'control_location': 'back-end'}
self.admin_encryption_types_client.update_encryption_type(
encrypt_type_id, **update_kwargs)
encrypt_type_id, encryption_id, **update_kwargs)
updated_encryption_type = (
self.admin_encryption_types_client.show_encryption_type(
encrypt_type_id))
@ -174,7 +175,7 @@ class VolumeTypesTest(base.BaseVolumeAdminTest):
# Delete encryption type
self.admin_encryption_types_client.delete_encryption_type(
encrypt_type_id)
encrypt_type_id, encryption_id)
self.admin_encryption_types_client.wait_for_resource_deletion(
encrypt_type_id)
deleted_encryption_type = (

View File

@ -69,21 +69,21 @@ class EncryptionTypesClient(rest_client.RestClient):
self.validate_response(schema.create_encryption_type, resp, body)
return rest_client.ResponseBody(resp, body)
def delete_encryption_type(self, volume_type_id):
def delete_encryption_type(self, volume_type_id, encryption_id):
"""Delete the encryption type for the specified volume-type."""
resp, body = self.delete(
"/types/%s/encryption/provider" % volume_type_id)
"/types/%s/encryption/%s" % (volume_type_id, encryption_id))
self.validate_response(schema.delete_encryption_type, resp, body)
return rest_client.ResponseBody(resp, body)
def update_encryption_type(self, volume_type_id, **kwargs):
def update_encryption_type(self, volume_type_id, encryption_id, **kwargs):
"""Update an encryption type for an existing volume type.
For a full list of available parameters, please refer to the official
API reference:
https://docs.openstack.org/api-ref/block-storage/v3/index.html#update-an-encryption-type
"""
url = "/types/%s/encryption/provider" % volume_type_id
url = "/types/%s/encryption/%s" % (volume_type_id, encryption_id)
put_body = json.dumps({'encryption': kwargs})
resp, body = self.put(url, put_body)
body = json.loads(body)

View File

@ -106,6 +106,7 @@ class TestEncryptionTypesClient(base.BaseServiceTest):
'tempest.lib.common.rest_client.RestClient.delete',
{},
volume_type_id="cbc36478b0bd8e67e89",
encryption_id="test_id",
status=202)
def test_update_encryption_type_with_str_body(self):
@ -119,4 +120,5 @@ class TestEncryptionTypesClient(base.BaseServiceTest):
self.client.update_encryption_type,
'tempest.lib.common.rest_client.RestClient.put',
self.FAKE_UPDATE_ENCRYPTION_TYPE,
bytes_body, volume_type_id="cbc36478b0bd8e67e89")
bytes_body, volume_type_id="cbc36478b0bd8e67e89",
encryption_id="test_id")