Add test for showing encryption specs item

This patch adds test for the missing API (volume v2):
show specific encryption specs item for a volume type.

Including:

[1] Add show encryption specs item API to v2 encryption_types_client
[2] Add unit test for the API
[3] Modify test case: test_volume_type_encryption_create_get_update_delete
[4] Add release note

Change-Id: Idd91e39716f4acf6796412f3f67ef8b6771916f9
This commit is contained in:
jeremy.zhang 2017-11-18 17:04:47 +08:00 committed by Jeremy Zhang
parent 9358cfb462
commit d88a250924
4 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
features:
- |
Add show encryption specs item API to v2 encryption_types_client library.
This feature enables the possibility to show specific encryption specs for
a volume type.

View File

@ -161,6 +161,12 @@ class VolumeTypesTest(base.BaseVolumeAdminTest):
'The fetched encryption_type %s is different '
'from the updated encryption_type' % key)
# Get encryption specs item
key = 'cipher'
item = self.admin_encryption_types_client.show_encryption_specs_item(
encrypt_type_id, key)
self.assertEqual(update_kwargs[key], item[key])
# Delete encryption type
self.admin_encryption_types_client.delete_encryption_type(
encrypt_type_id)

View File

@ -47,6 +47,14 @@ class EncryptionTypesClient(rest_client.RestClient):
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def show_encryption_specs_item(self, volume_type_id, key):
"""Get the encryption specs item for the specified volume type."""
url = "/types/%s/encryption/%s" % (volume_type_id, key)
resp, body = self.get(url)
body = json.loads(body)
self.expected_success(200, resp.status)
return rest_client.ResponseBody(resp, body)
def create_encryption_type(self, volume_type_id, **kwargs):
"""Create encryption type.

View File

@ -43,6 +43,10 @@ class TestEncryptionTypesClient(base.BaseServiceTest):
}
}
FAKE_ENCRYPTION_SPECS_ITEM = {
"cipher": "aes-xts-plain64"
}
def setUp(self):
super(TestEncryptionTypesClient, self).setUp()
fake_auth = fake_auth_provider.FakeAuthProvider()
@ -65,6 +69,13 @@ class TestEncryptionTypesClient(base.BaseServiceTest):
self.FAKE_INFO_ENCRYPTION_TYPE,
bytes_body, volume_type_id="cbc36478b0bd8e67e89")
def _test_show_encryption_specs_item(self, bytes_body=False):
self.check_service_client_function(
self.client.show_encryption_specs_item,
'tempest.lib.common.rest_client.RestClient.get',
self.FAKE_ENCRYPTION_SPECS_ITEM,
bytes_body, volume_type_id="cbc36478b0bd8e67e89", key="cipher")
def test_create_encryption_type_with_str_body(self):
self._test_create_encryption()
@ -77,6 +88,12 @@ class TestEncryptionTypesClient(base.BaseServiceTest):
def test_show_encryption_type_with_bytes_body(self):
self._test_show_encryption_type(bytes_body=True)
def test_show_encryption_specs_item_with_str_body(self):
self._test_show_encryption_specs_item()
def test_show_encryption_specs_item_with_bytes_body(self):
self._test_show_encryption_specs_item(bytes_body=True)
def test_delete_encryption_type(self):
self.check_service_client_function(
self.client.delete_encryption_type,