How to use delete_namespace_tags method in tempest

Best Python code snippet using tempest_python

test_image_namespace_tags_rbac.py

Source:test_image_namespace_tags_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_base as base20class NamespaceTagsRbacTest(base.BaseV2ImageRbacTest):21 """RBAC tests for namespace_tags_client.22 Performs RBAC testing for the endpoints in namespace_tags_client, except23 for24 1) delete_namespace_tag25 2) delete_namespace_tags26 because Glance does not currently do policy enforcement for them.27 """28 @classmethod29 def resource_setup(cls):30 super(NamespaceTagsRbacTest, cls).resource_setup()31 cls.namespace = cls.namespaces_client.create_namespace(32 namespace=data_utils.rand_name(33 cls.__name__ + '-namespace'))['namespace']34 cls.addClassResourceCleanup(35 cls.namespaces_client.delete_namespace,36 cls.namespace)37 def _create_namespace_tag(self, multiple=False):38 tag_count = 2 if multiple else 139 namespace_tag_names = []40 for i in range(tag_count):41 tag_name = data_utils.rand_name(self.__class__.__name__ + '-tag')42 namespace_tag_names.append({'name': tag_name})43 if multiple:44 namespace_tags = self.namespace_tags_client.create_namespace_tags(45 self.namespace, tags=namespace_tag_names)['tags']46 else:47 namespace_tags = self.namespace_tags_client.create_namespace_tag(48 self.namespace, namespace_tag_names[0]['name'])49 self.addCleanup(test_utils.call_and_ignore_notfound_exc,50 self.namespace_tags_client.delete_namespace_tags,51 self.namespace)52 return [nt['name'] for nt in namespace_tags] if multiple \53 else namespace_tags['name']54 @decorators.idempotent_id('50bedccb-9d0b-4138-8d95-31a89250edf6')55 @rbac_rule_validation.action(service="glance",56 rules=["add_metadef_tag"])57 def test_create_namespace_tag(self):58 with self.override_role():59 self._create_namespace_tag()60 @decorators.idempotent_id('4acf70cc-05da-4b1e-87b2-d5e4475164e7')61 @rbac_rule_validation.action(service="glance",62 rules=["get_metadef_tag"])63 def test_show_namespace_tag(self):64 tag_name = self._create_namespace_tag()65 with self.override_role():66 self.namespace_tags_client.show_namespace_tag(self.namespace,67 tag_name)68 @decorators.idempotent_id('01593828-3edb-461e-8abc-8fdeb3927e37')69 @rbac_rule_validation.action(service="glance",70 rules=["modify_metadef_tag"])71 def test_update_namespace_tag(self):72 tag_name = self._create_namespace_tag()73 updated_tag_name = data_utils.rand_name(74 self.__class__.__name__ + '-tag')75 with self.override_role():76 self.namespace_tags_client.update_namespace_tag(77 self.namespace, tag_name, name=updated_tag_name)78 @decorators.idempotent_id('20ffaf76-ebdc-4267-a1ad-194346f5cc91')79 @rbac_rule_validation.action(service="glance",80 rules=["add_metadef_tags"])81 def test_create_namespace_tags(self):82 with self.override_role():83 self._create_namespace_tag(multiple=True)84 @decorators.idempotent_id('d37c1501-e787-449d-89b3-754a942a459a')85 @rbac_rule_validation.action(service="glance",86 rules=["get_metadef_tags"])87 def test_list_namespace_tags(self):88 with self.override_role():...

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