Merge "[srbac] Testing Volume Actions"
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 VolumeV3RbacVolumeActionsTests(rbac_base.VolumeV3RbacBaseTests): | |
| 22 | ||
| 23 | @classmethod | |
| 24 | def setup_clients(cls): | |
| 25 | super().setup_clients() | |
| 26 | cls.vol_other_client = cls.os_project_admin.volumes_client_latest | |
| 27 | ||
| 28 | def _extend_volume(self, expected_status): | |
| 29 | """Test extend_volume operation. | |
| 30 | ||
| 31 | Args: | |
| 32 | expected_status: The expected HTTP response code | |
| 33 | """ | |
| 34 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 35 | self.do_request( | |
| 36 | method='extend_volume', volume_id=volume_id, | |
| 37 | new_size=2, expected_status=expected_status | |
| 38 | ) | |
| 39 | ||
| 40 | def _reset_volume_status(self, expected_status): | |
| 41 | """Test reset_volume_status operation. | |
| 42 | ||
| 43 | Args: | |
| 44 | expected_status: The expected HTTP response code | |
| 45 | """ | |
| 46 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 47 | self.do_request( | |
| 48 | method='reset_volume_status', volume_id=volume_id, | |
| 49 | status='error', expected_status=expected_status | |
| 50 | ) | |
| 51 | ||
| 52 | def _retype_volume(self, expected_status): | |
| 53 | """Test retype_volume operation. | |
| 54 | ||
| 55 | Args: | |
| 56 | expected_status: The expected HTTP response code | |
| 57 | """ | |
| 58 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 59 | self.do_request( | |
| 60 | method='retype_volume', volume_id=volume_id, | |
| 61 | new_type='dedup-tier-replication', expected_status=expected_status | |
| 62 | ) | |
| 63 | ||
| 64 | def _update_volume_readonly(self, expected_status): | |
| 65 | """Test update_volume_readonly operation. | |
| 66 | ||
| 67 | Args: | |
| 68 | expected_status: The expected HTTP response code | |
| 69 | """ | |
| 70 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 71 | self.do_request( | |
| 72 | method='update_volume_readonly', volume_id=volume_id, | |
| 73 | readonly=True, expected_status=expected_status | |
| 74 | ) | |
| 75 | ||
| 76 | def _force_delete_volume(self, expected_status): | |
| 77 | """Test force_delete_volume operation. | |
| 78 | ||
| 79 | Args: | |
| 80 | expected_status: The expected HTTP response code | |
| 81 | """ | |
| 82 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 83 | self.do_request( | |
| 84 | method='force_delete_volume', volume_id=volume_id, | |
| 85 | expected_status=expected_status | |
| 86 | ) | |
| 87 | ||
| 88 | def _reserve_volume(self, expected_status): | |
| 89 | """Test reserve_volume operation. | |
| 90 | ||
| 91 | Args: | |
| 92 | expected_status: The expected HTTP response code | |
| 93 | """ | |
| 94 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 95 | self.do_request( | |
| 96 | method='reserve_volume', volume_id=volume_id, | |
| 97 | expected_status=expected_status | |
| 98 | ) | |
| 99 | ||
| 100 | def _unreserve_volume(self, expected_status): | |
| 101 | """Test unreserve_volume operation. | |
| 102 | ||
| 103 | Args: | |
| 104 | expected_status: The expected HTTP response code | |
| 105 | """ | |
| 106 | volume_id = self.create_volume(client=self.vol_other_client) | |
| 107 | self.do_request( | |
| 108 | method='unreserve_volume', volume_id=volume_id, | |
| 109 | expected_status=expected_status | |
| 110 | ) | |
| 111 | ||
| 112 | ||
| 113 | class ProjectReaderTests(VolumeV3RbacVolumeActionsTests): | |
| 114 | ||
| 115 | credentials = ['project_reader', 'project_admin'] | |
| 116 | ||
| 117 | @classmethod | |
| 118 | def setup_clients(cls): | |
| 119 | super().setup_clients() | |
| 120 | cls.client = cls.os_project_reader.volumes_client_latest | |
| 121 | ||
| 122 | @decorators.skip_because(bug="2020261") | |
| 123 | @decorators.idempotent_id('4d721c58-2f6f-4857-8f4f-0664d5f7bf49') | |
| 124 | def test_extend_volume(self): | |
| 125 | self._extend_volume(expected_status=exceptions.Forbidden) | |
| 126 | ||
| 127 | @decorators.idempotent_id('434b454a-5cbe-492d-a416-70b8ff41f636') | |
| 128 | def test_reset_volume_status(self): | |
| 129 | self._reset_volume_status(expected_status=exceptions.Forbidden) | |
| 130 | ||
| 131 | @decorators.skip_because(bug="2020261") | |
| 132 | @decorators.idempotent_id('4675295a-7c72-4b04-8a43-03d7c88ab6bf') | |
| 133 | def test_retype_volume(self): | |
| 134 | self._retype_volume(expected_status=exceptions.Forbidden) | |
| 135 | ||
| 136 | @decorators.skip_because(bug="2020261") | |
| 137 | @decorators.idempotent_id('3beecd52-e314-40d8-875d-a0e7db8dd88f') | |
| 138 | def test_update_volume_readonly(self): | |
| 139 | self._update_volume_readonly(expected_status=exceptions.Forbidden) | |
| 140 | ||
| 141 | @decorators.idempotent_id('b025ff12-73a4-4f15-af55-876cd43cade3') | |
| 142 | def test_force_delete_volume(self): | |
| 143 | self._force_delete_volume(expected_status=exceptions.Forbidden) | |
| 144 | ||
| 145 | @decorators.skip_because(bug="2020261") | |
| 146 | @decorators.idempotent_id('d2c13bf9-267a-4a71-be5c-391f22e9b433') | |
| 147 | def test_reserve_volume(self): | |
| 148 | self._reserve_volume(expected_status=exceptions.Forbidden) | |
| 149 | ||
| 150 | @decorators.skip_because(bug="2020261") | |
| 151 | @decorators.idempotent_id('725d85cf-96b2-4338-98f4-2f468099c4ed') | |
| 152 | def test_unreserve_volume(self): | |
| 153 | self._unreserve_volume(expected_status=exceptions.Forbidden) |