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 <evan.wever@gmail.com>
Change-Id: Ieca29000b5754373e6250818ccf2b3b6d4ef80e2
diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py
index 5b17afb..0f032c6 100644
--- a/tempest/api/volume/admin/test_volume_types.py
+++ b/tempest/api/volume/admin/test_volume_types.py
@@ -143,6 +143,7 @@
# 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 @@
'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 @@
# 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 7cced57..f6f2fd5 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 @@
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 7218224..8164ea6 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 @@
'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 @@
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")