Merge "[srbac] Testing Volumes"
Zuul authored 2 years ago
Gerrit Code Review committed 2 years ago
| 0 | # Licensed under the Apache License, Version 2.0 (the "License"); you may | |
| 1 | # not use this file except in compliance with the License. You may obtain | |
| 2 | # a copy of the License at | |
| 3 | # | |
| 4 | # http://www.apache.org/licenses/LICENSE-2.0 | |
| 5 | # | |
| 6 | # Unless required by applicable law or agreed to in writing, software | |
| 7 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
| 8 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
| 9 | # License for the specific language governing permissions and limitations | |
| 10 | # under the License. | |
| 11 | ||
| 12 | from tempest import config | |
| 13 | from tempest.lib import decorators | |
| 14 | from tempest.lib import exceptions | |
| 15 | ||
| 16 | from cinder_tempest_plugin.rbac.v3 import base as rbac_base | |
| 17 | ||
| 18 | CONF = config.CONF | |
| 19 | ||
| 20 | ||
| 21 | class VolumeV3RbacVolumesTests(rbac_base.VolumeV3RbacBaseTests): | |
| 22 | ||
| 23 | min_microversion = '3.12' | |
| 24 | ||
| 25 | @classmethod | |
| 26 | def setup_clients(cls): | |
| 27 | super().setup_clients() | |
| 28 | cls.vol_other_client = cls.os_project_admin.volumes_client_latest | |
| 29 | ||
| 30 | def _create_volume(self, expected_status, **kwargs): | |
| 31 | """Test create_volume operation. | |
| 32 | ||
| 33 | Args: | |
| 34 | expected_status: The expected HTTP response code | |
| 35 | """ | |
| 36 | kwargs['size'] = CONF.volume.volume_size | |
| 37 | self.do_request( | |
| 38 | method='create_volume', expected_status=expected_status, **kwargs | |
| 39 | ) | |
| 40 | ||
| 41 | def _show_volume(self, expected_status): | |
| 42 | """Test show_volume operation | |
| 43 | ||
| 44 | Args: | |
| 45 | expected_status: The expected HTTP response code | |
| 46 | """ | |
| 47 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 48 | self.do_request( | |
| 49 | method='show_volume', volume_id=volume_id, | |
| 50 | expected_status=expected_status | |
| 51 | ) | |
| 52 | ||
| 53 | def _list_volumes(self, expected_status): | |
| 54 | """Test list_volumes operation | |
| 55 | ||
| 56 | Args: | |
| 57 | expected_status: The expected HTTP response code | |
| 58 | """ | |
| 59 | self.create_volume(client=self.vol_other_client) | |
| 60 | self.do_request(method='list_volumes', expected_status=expected_status) | |
| 61 | ||
| 62 | def _list_volumes_detail(self, expected_status): | |
| 63 | """Test list_volumes details operation | |
| 64 | ||
| 65 | Args: | |
| 66 | expected_status: The expected HTTP response code | |
| 67 | """ | |
| 68 | self.create_volume(client=self.vol_other_client) | |
| 69 | self.do_request( | |
| 70 | method='list_volumes', detail=True, expected_status=expected_status | |
| 71 | ) | |
| 72 | ||
| 73 | def _show_volume_summary(self, expected_status): | |
| 74 | """Test show_volume_summary operation | |
| 75 | ||
| 76 | Args: | |
| 77 | expected_status: The expected HTTP response code | |
| 78 | """ | |
| 79 | self.create_volume(client=self.vol_other_client) | |
| 80 | self.do_request( | |
| 81 | method='show_volume_summary', expected_status=expected_status | |
| 82 | ) | |
| 83 | ||
| 84 | def _update_volume(self, expected_status): | |
| 85 | """Test update_volume operation. | |
| 86 | ||
| 87 | Args: | |
| 88 | expected_status: The expected HTTP response code | |
| 89 | """ | |
| 90 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 91 | new_desc = self.__name__ + '-update_test' | |
| 92 | self.do_request( | |
| 93 | method='update_volume', volume_id=volume_id, description=new_desc, | |
| 94 | expected_status=expected_status | |
| 95 | ) | |
| 96 | ||
| 97 | def _set_bootable_volume(self, expected_status): | |
| 98 | """Test set_bootable_volume operation. | |
| 99 | ||
| 100 | Args: | |
| 101 | expected_status: The expected HTTP response code | |
| 102 | """ | |
| 103 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 104 | self.do_request( | |
| 105 | method='set_bootable_volume', volume_id=volume_id, | |
| 106 | bootable=True, expected_status=expected_status | |
| 107 | ) | |
| 108 | ||
| 109 | def _delete_volume(self, expected_status): | |
| 110 | """Test delete_volume operation. | |
| 111 | ||
| 112 | Args: | |
| 113 | expected_status: The expected HTTP response code | |
| 114 | """ | |
| 115 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 116 | self.do_request( | |
| 117 | method='delete_volume', volume_id=volume_id, | |
| 118 | expected_status=expected_status | |
| 119 | ) | |
| 120 | ||
| 121 | ||
| 122 | class ProjectReaderTests(VolumeV3RbacVolumesTests): | |
| 123 | ||
| 124 | credentials = ['project_reader', 'project_admin'] | |
| 125 | ||
| 126 | @classmethod | |
| 127 | def setup_clients(cls): | |
| 128 | super().setup_clients() | |
| 129 | cls.client = cls.os_project_reader.volumes_client_latest | |
| 130 | ||
| 131 | @decorators.skip_because(bug="2020113") | |
| 132 | @decorators.idempotent_id('3d87f960-6210-45f5-b70b-679d67a4e17e') | |
| 133 | def test_create_volume(self): | |
| 134 | self._create_volume(expected_status=exceptions.Forbidden) | |
| 135 | ||
| 136 | @decorators.idempotent_id('9b2667f2-744e-4d1f-8c39-17060010f19f') | |
| 137 | def test_show_volume(self): | |
| 138 | self._show_volume(expected_status=200) | |
| 139 | ||
| 140 | @decorators.idempotent_id('2f4da8f9-cdc5-4a6e-9143-8237634a629c') | |
| 141 | def test_list_volumes(self): | |
| 142 | self._list_volumes(expected_status=200) | |
| 143 | ||
| 144 | @decorators.idempotent_id('b11e59cd-d1dd-43e4-9676-22ab394f5d18') | |
| 145 | def test_list_volumes_detail(self): | |
| 146 | self._list_volumes_detail(expected_status=200) | |
| 147 | ||
| 148 | @decorators.idempotent_id('ef347930-54dc-432f-b742-0a060fc37ae8') | |
| 149 | def test_show_volume_summary(self): | |
| 150 | self._show_volume_summary(expected_status=200) | |
| 151 | ||
| 152 | @decorators.skip_because(bug="2020113") | |
| 153 | @decorators.idempotent_id('cda92972-7213-4fa0-bc14-ab012dc95931') | |
| 154 | def test_update_volume(self): | |
| 155 | self._update_volume(expected_status=exceptions.Forbidden) | |
| 156 | ||
| 157 | @decorators.skip_because(bug="2020113") | |
| 158 | @decorators.idempotent_id('9970b57d-8d5d-460e-931b-28a112df81e0') | |
| 159 | def test_set_bootable_volume(self): | |
| 160 | self._set_bootable_volume(expected_status=exceptions.Forbidden) | |
| 161 | ||
| 162 | @decorators.skip_because(bug="2020113") | |
| 163 | @decorators.idempotent_id('4fd4dce8-ed8a-4f05-8aac-da99858b563d') | |
| 164 | def test_delete_volume(self): | |
| 165 | self._delete_volume(expected_status=exceptions.Forbidden) |