Best Python code snippet using tempest_python
test_groups_rbac.py
Source:test_groups_rbac.py
...18from patrole_tempest_plugin.tests.api.identity import rbac_base19class IdentityGroupsV3RbacTest(rbac_base.BaseIdentityV3RbacTest):20 def _create_user_and_add_to_new_group(self):21 """Creates a user and adds to a group for test."""22 group = self.setup_test_group()23 user = self.setup_test_user()24 self.groups_client.add_group_user(group['id'], user['id'])25 return (group['id'], user['id'])26 @rbac_rule_validation.action(service="keystone",27 rule="identity:create_group")28 @decorators.idempotent_id('88377f51-9074-4d64-a22f-f8931d048c9a')29 def test_create_group(self):30 self.rbac_utils.switch_role(self, toggle_rbac_role=True)31 self.setup_test_group()32 @rbac_rule_validation.action(service="keystone",33 rule="identity:update_group")34 @decorators.idempotent_id('790fb7be-a657-4a64-9b83-c43425cf180b')35 def test_update_group(self):36 group = self.setup_test_group()37 new_group_name = data_utils.rand_name(38 self.__class__.__name__ + '-group')39 self.rbac_utils.switch_role(self, toggle_rbac_role=True)40 self.groups_client.update_group(group['id'],41 name=new_group_name)42 @rbac_rule_validation.action(service="keystone",43 rule="identity:delete_group")44 @decorators.idempotent_id('646b52da-2a5f-486a-afb0-51fdc86a6c12')45 def test_delete_group(self):46 group = self.setup_test_group()47 self.rbac_utils.switch_role(self, toggle_rbac_role=True)48 self.groups_client.delete_group(group['id'])49 @rbac_rule_validation.action(service="keystone",50 rule="identity:get_group")51 @decorators.idempotent_id('d530f0ad-42b9-429b-ad05-e53ac95a040e')52 def test_show_group(self):53 group = self.setup_test_group()54 self.rbac_utils.switch_role(self, toggle_rbac_role=True)55 self.groups_client.show_group(group['id'])56 @rbac_rule_validation.action(service="keystone",57 rule="identity:list_groups")58 @decorators.idempotent_id('c4d0f76b-735f-4fd0-868b-0006bc420ff4')59 def test_list_groups(self):60 self.rbac_utils.switch_role(self, toggle_rbac_role=True)61 self.groups_client.list_groups()62 @rbac_rule_validation.action(service="keystone",63 rule="identity:add_user_to_group")64 @decorators.idempotent_id('fdd49b74-3ed3-4736-9f0e-9027a32017ac')65 def test_add_user_group(self):66 group = self.setup_test_group()67 user = self.setup_test_user()68 self.rbac_utils.switch_role(self, toggle_rbac_role=True)69 self.groups_client.add_group_user(group['id'], user['id'])70 @rbac_rule_validation.action(service="keystone",71 rule="identity:remove_user_from_group")72 @decorators.idempotent_id('8a60d11c-7d2b-47e5-a0f3-9ea900ca66fe')73 def test_remove_user_group(self):74 group_id, user_id = self._create_user_and_add_to_new_group()75 self.rbac_utils.switch_role(self, toggle_rbac_role=True)76 self.groups_client.delete_group_user(group_id, user_id)77 @rbac_rule_validation.action(service="keystone",78 rule="identity:list_users_in_group")79 @decorators.idempotent_id('b3e394a7-079e-4a0d-a4ff-9b266293d1ee')80 def test_list_user_group(self):81 group = self.setup_test_group()82 self.rbac_utils.switch_role(self, toggle_rbac_role=True)83 self.groups_client.list_group_users(group['id'])84 @rbac_rule_validation.action(service="keystone",85 rule="identity:check_user_in_group")86 @decorators.idempotent_id('d3603241-fd87-4a2d-94f9-f32469d1aaba')87 def test_check_user_group(self):88 group_id, user_id = self._create_user_and_add_to_new_group()89 self.rbac_utils.switch_role(self, toggle_rbac_role=True)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!