How to use remove_type_access method in tempest

Best Python code snippet using tempest_python

test_volume_type_access.py

Source:test_volume_type_access.py Github

copy

Full Screen

1# Copyright 2016 OpenStack Foundation2# All Rights Reserved.3#4# Licensed under the Apache License, Version 2.0 (the "License"); you may5# not use this file except in compliance with the License. You may obtain6# a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing, software11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the13# License for the specific language governing permissions and limitations14# under the License.15import operator16from tempest.api.volume import base17from tempest import config18from tempest.lib import decorators19from tempest.lib import exceptions as lib_exc20CONF = config.CONF21class VolumeTypesAccessV2Test(base.BaseVolumeAdminTest):22 credentials = ['primary', 'alt', 'admin']23 @classmethod24 def setup_clients(cls):25 super(VolumeTypesAccessV2Test, cls).setup_clients()26 cls.alt_client = cls.os_alt.volumes_client27 @decorators.idempotent_id('d4dd0027-835f-4554-a6e5-50903fb79184')28 def test_volume_type_access_add(self):29 # Creating a NON public volume type30 params = {'os-volume-type-access:is_public': False}31 volume_type = self.create_volume_type(**params)32 # Try creating a volume from volume type in primary tenant33 self.assertRaises(lib_exc.NotFound, self.volumes_client.create_volume,34 volume_type=volume_type['id'],35 size=CONF.volume.volume_size)36 # Adding volume type access for primary tenant37 self.admin_volume_types_client.add_type_access(38 volume_type['id'], project=self.volumes_client.tenant_id)39 self.addCleanup(self.admin_volume_types_client.remove_type_access,40 volume_type['id'],41 project=self.volumes_client.tenant_id)42 # Creating a volume from primary tenant43 volume = self.create_volume(volume_type=volume_type['id'])44 # Validating the created volume is based on the volume type45 self.assertEqual(volume_type['name'], volume['volume_type'])46 @decorators.idempotent_id('5220eb28-a435-43ce-baaf-ed46f0e95159')47 def test_volume_type_access_list(self):48 # Creating a NON public volume type49 params = {'os-volume-type-access:is_public': False}50 volume_type = self.create_volume_type(**params)51 # Adding volume type access for primary tenant52 self.admin_volume_types_client.add_type_access(53 volume_type['id'], project=self.volumes_client.tenant_id)54 self.addCleanup(self.admin_volume_types_client.remove_type_access,55 volume_type['id'],56 project=self.volumes_client.tenant_id)57 # Adding volume type access for alt tenant58 self.admin_volume_types_client.add_type_access(59 volume_type['id'], project=self.alt_client.tenant_id)60 self.addCleanup(self.admin_volume_types_client.remove_type_access,61 volume_type['id'],62 project=self.alt_client.tenant_id)63 # List tenant access for the given volume type64 type_access_list = self.admin_volume_types_client.list_type_access(65 volume_type['id'])['volume_type_access']66 volume_type_ids = [67 vol_type['volume_type_id'] for vol_type in type_access_list68 ]69 # Validating volume type available for only two tenants70 self.assertEqual(2, volume_type_ids.count(volume_type['id']))71 # Validating the permitted tenants are the expected tenants72 self.assertIn(self.volumes_client.tenant_id,73 map(operator.itemgetter('project_id'), type_access_list))74 self.assertIn(self.alt_client.tenant_id,...

Full Screen

Full Screen

test_volume_types_access_rbac.py

Source:test_volume_types_access_rbac.py Github

copy

Full Screen

...60 @decorators.idempotent_id('8f848aeb-636a-46f1-aeeb-e2a60e9d2bfe')61 @rbac_rule_validation.action(62 service="cinder",63 rule="volume_extension:volume_type_access:removeProjectAccess")64 def test_remove_type_access(self):65 self._add_type_access(ignore_not_found=True)66 self.rbac_utils.switch_role(self, toggle_rbac_role=True)67 self.volume_types_client.remove_type_access(...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful