blob: d1a11e5d8eda5a4b31519e09b3567465e34077f5 [file] [log] [blame]
Lance Bragstadd3fddec2021-02-16 16:27:13 +00001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13from tempest import config
14
15CONF = config.CONF
16
17
18class VolumeV3RbacBaseTests(object):
19
20 identity_version = 'v3'
21
22 @classmethod
23 def skip_checks(cls):
24 super(VolumeV3RbacBaseTests, cls).skip_checks()
25 if not CONF.enforce_scope.cinder:
26 raise cls.skipException(
27 "Tempest is not configured to enforce_scope for cinder, "
28 "skipping RBAC tests. To enable these tests set "
29 "`tempest.conf [enforce_scope] cinder=True`."
30 )
31
32 def do_request(self, method, expected_status=200, client=None, **payload):
33 if not client:
34 client = self.client
35 if isinstance(expected_status, type(Exception)):
36 self.assertRaises(expected_status,
37 getattr(client, method),
38 **payload)
39 else:
40 response = getattr(client, method)(**payload)
41 self.assertEqual(response.response.status, expected_status)
42 return response