How to use delete_namespace_object method in tempest

Best Python code snippet using tempest_python

test_image_namespace_objects_rbac.py

Source:test_image_namespace_objects_rbac.py Github

copy

Full Screen

1# Copyright 2017 AT&T Corporation.2# 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.15from tempest.lib.common.utils import data_utils16from tempest.lib.common.utils import test_utils17from tempest.lib import decorators18from patrole_tempest_plugin import rbac_rule_validation19from patrole_tempest_plugin.tests.api.image import rbac_base20class ImageNamespacesObjectsRbacTest(rbac_base.BaseV2ImageRbacTest):21 @rbac_rule_validation.action(service="glance",22 rules=["add_metadef_object"])23 @decorators.idempotent_id("772156f2-e33d-432e-8521-12385746c2f0")24 def test_create_metadef_object_in_namespace(self):25 """Create Metadef Object Namespace Test26 RBAC test for the glance add_metadef_object policy27 """28 namespace = self.create_namespace()29 # create a md object, it will be cleaned automatically after30 # cleanup of namespace31 object_name = data_utils.rand_name(32 self.__class__.__name__ + '-test-object')33 with self.override_role():34 self.namespace_objects_client.create_namespace_object(35 namespace['namespace'],36 name=object_name)37 self.addCleanup(test_utils.call_and_ignore_notfound_exc,38 self.namespace_objects_client.delete_namespace_object,39 namespace['namespace'], object_name)40 @rbac_rule_validation.action(service="glance",41 rules=["get_metadef_objects"])42 @decorators.idempotent_id("48b50ecb-237d-4909-be62-b6a05c47b64d")43 def test_list_metadef_objects_in_namespace(self):44 """List Metadef Object Namespace Test45 RBAC test for the glance get_metadef_objects policy46 """47 namespace = self.create_namespace()48 with self.override_role():49 # list md objects50 self.namespace_objects_client.list_namespace_objects(51 namespace['namespace'])52 @rbac_rule_validation.action(service="glance",53 rules=["modify_metadef_object"])54 @decorators.idempotent_id("cd130b1d-89fa-479c-a90e-498d895fb455")55 def test_update_metadef_object_in_namespace(self):56 """Update Metadef Object Namespace Test57 RBAC test for the glance modify_metadef_object policy58 """59 namespace = self.create_namespace()60 object_name = data_utils.rand_name(61 self.__class__.__name__ + '-test-object')62 self.namespace_objects_client.create_namespace_object(63 namespace['namespace'],64 name=object_name)65 self.addCleanup(test_utils.call_and_ignore_notfound_exc,66 self.namespace_objects_client.delete_namespace_object,67 namespace['namespace'], object_name)68 # Toggle role and modify object69 new_name = "Object New Name"70 with self.override_role():71 self.namespace_objects_client.update_namespace_object(72 namespace['namespace'], object_name, name=new_name)73 @rbac_rule_validation.action(service="glance",74 rules=["get_metadef_object"])75 @decorators.idempotent_id("93c61420-5b80-4a0e-b6f3-4ccc6e90b865")76 def test_show_metadef_object_in_namespace(self):77 """Show Metadef Object Namespace Test78 RBAC test for the glance get_metadef_object policy79 """80 namespace = self.create_namespace()81 object_name = data_utils.rand_name(82 self.__class__.__name__ + '-test-object')83 self.namespace_objects_client.create_namespace_object(84 namespace['namespace'],85 name=object_name)86 self.addCleanup(test_utils.call_and_ignore_notfound_exc,87 self.namespace_objects_client.delete_namespace_object,88 namespace['namespace'], object_name)89 # Toggle role and get object90 with self.override_role():91 self.namespace_objects_client.show_namespace_object(92 namespace['namespace'],...

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