From d88a250924c034ba1c82793e04e99c95f037525e Mon Sep 17 00:00:00 2001 From: "jeremy.zhang" Date: Sat, 18 Nov 2017 17:04:47 +0800 Subject: [PATCH] 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 --- ...ncryption-types-client-290b421cd4bc0c0e.yaml | 6 ++++++ tempest/api/volume/admin/test_volume_types.py | 6 ++++++ .../volume/v2/encryption_types_client.py | 8 ++++++++ .../volume/v2/test_encryption_types_client.py | 17 +++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 releasenotes/notes/add-show-encryption-specs-item-api-to-v2-encryption-types-client-290b421cd4bc0c0e.yaml diff --git a/releasenotes/notes/add-show-encryption-specs-item-api-to-v2-encryption-types-client-290b421cd4bc0c0e.yaml b/releasenotes/notes/add-show-encryption-specs-item-api-to-v2-encryption-types-client-290b421cd4bc0c0e.yaml new file mode 100644 index 0000000000..9e13afcc33 --- /dev/null +++ b/releasenotes/notes/add-show-encryption-specs-item-api-to-v2-encryption-types-client-290b421cd4bc0c0e.yaml @@ -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. diff --git a/tempest/api/volume/admin/test_volume_types.py b/tempest/api/volume/admin/test_volume_types.py index af1024c936..1077524087 100644 --- a/tempest/api/volume/admin/test_volume_types.py +++ b/tempest/api/volume/admin/test_volume_types.py @@ -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) diff --git a/tempest/lib/services/volume/v2/encryption_types_client.py b/tempest/lib/services/volume/v2/encryption_types_client.py index 20f3356b4b..b99d1febd0 100644 --- a/tempest/lib/services/volume/v2/encryption_types_client.py +++ b/tempest/lib/services/volume/v2/encryption_types_client.py @@ -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. diff --git a/tempest/tests/lib/services/volume/v2/test_encryption_types_client.py b/tempest/tests/lib/services/volume/v2/test_encryption_types_client.py index d0290911e7..8de9fb481a 100644 --- a/tempest/tests/lib/services/volume/v2/test_encryption_types_client.py +++ b/tempest/tests/lib/services/volume/v2/test_encryption_types_client.py @@ -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,