From 5e1a714cfe3ba78c1fb8e60f06f91a864584bec5 Mon Sep 17 00:00:00 2001 From: Evan Wever Date: Mon, 15 Jul 2024 11:52:37 -0400 Subject: [PATCH] Fixed encryption type methods to comply with documentation This change fixes an optional `encryption_id` parameter for updating and deleting encryption types to comply with OpenStack documentation. `encryption_id` is optional because only one `encryption_id` can be associated with a `volume type`, therefore, an encryption type is deleted using `volume type`. `encryption_id` is only used for Cinder notifications. Closes-bug: #1835186 Co-Authored-By: Evan Wever Change-Id: Ieca29000b5754373e6250818ccf2b3b6d4ef80e2 --- tempest/api/volume/admin/test_volume_types.py | 5 +++-- tempest/lib/services/volume/v3/encryption_types_client.py | 8 ++++---- .../services/volume/v3/test_encryption_types_client.py | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py index 5b17afb59e..0f032c63c3 100644 --- a/tempest/api/volume/admin/test_volume_types.py +++ b/tempest/api/volume/admin/test_volume_types.py @@ -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 = ( diff --git a/tempest/lib/services/volume/v3/encryption_types_client.py b/tempest/lib/services/volume/v3/encryption_types_client.py index 7cced57c28..f6f2fd5147 100644 --- a/tempest/lib/services/volume/v3/encryption_types_client.py +++ b/tempest/lib/services/volume/v3/encryption_types_client.py @@ -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) diff --git a/tempest/tests/lib/services/volume/v3/test_encryption_types_client.py b/tempest/tests/lib/services/volume/v3/test_encryption_types_client.py index 7218224257..8164ea664c 100644 --- a/tempest/tests/lib/services/volume/v3/test_encryption_types_client.py +++ b/tempest/tests/lib/services/volume/v3/test_encryption_types_client.py @@ -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")