How to use create_user_role_on_project method in tempest

Best Python code snippet using tempest_python

test_roles_negative.py

Source:test_roles_negative.py Github

copy

Full Screen

...145 @test.idempotent_id('5c3132cd-c4c8-4402-b5ea-71eb44e97793')146 def test_assign_duplicate_user_role(self):147 # Duplicate user role should not get assigned148 (user, tenant, role) = self._get_role_params()149 self.roles_client.create_user_role_on_project(tenant['id'],150 user['id'],151 role['id'])152 self.assertRaises(lib_exc.Conflict,153 self.roles_client.create_user_role_on_project,154 tenant['id'], user['id'], role['id'])155 @test.attr(type=['negative'])156 @test.idempotent_id('d0537987-0977-448f-a435-904c15de7298')157 def test_remove_user_role_by_unauthorized_user(self):158 # Non-administrator user should not be authorized to159 # remove a user's role160 (user, tenant, role) = self._get_role_params()161 self.roles_client.create_user_role_on_project(tenant['id'],162 user['id'],163 role['id'])164 self.assertRaises(165 lib_exc.Forbidden,166 self.non_admin_roles_client.delete_role_from_user_on_project,167 tenant['id'], user['id'], role['id'])168 @test.attr(type=['negative'])169 @test.idempotent_id('cac81cf4-c1d2-47dc-90d3-f2b7eb572286')170 def test_remove_user_role_request_without_token(self):171 # Request to remove a user's role without a valid token172 (user, tenant, role) = self._get_role_params()173 self.roles_client.create_user_role_on_project(tenant['id'],174 user['id'],175 role['id'])176 token = self.client.auth_provider.get_token()177 self.client.delete_token(token)178 self.assertRaises(lib_exc.Unauthorized,179 self.roles_client.delete_role_from_user_on_project,180 tenant['id'], user['id'], role['id'])181 self.client.auth_provider.clear_auth()182 @test.attr(type=['negative'])183 @test.idempotent_id('ab32d759-cd16-41f1-a86e-44405fa9f6d2')184 def test_remove_user_role_non_existent_role(self):185 # Attempt to delete a non existent role from a user should fail186 (user, tenant, role) = self._get_role_params()187 self.roles_client.create_user_role_on_project(tenant['id'],188 user['id'],189 role['id'])190 non_existent_role = data_utils.rand_uuid_hex()191 self.assertRaises(lib_exc.NotFound,192 self.roles_client.delete_role_from_user_on_project,193 tenant['id'], user['id'], non_existent_role)194 @test.attr(type=['negative'])195 @test.idempotent_id('67a679ec-03dd-4551-bbfc-d1c93284f023')196 def test_remove_user_role_non_existent_tenant(self):197 # Attempt to remove a role from a non existent tenant should fail198 (user, tenant, role) = self._get_role_params()199 self.roles_client.create_user_role_on_project(tenant['id'],200 user['id'],201 role['id'])202 non_existent_tenant = data_utils.rand_uuid_hex()203 self.assertRaises(lib_exc.NotFound,204 self.roles_client.delete_role_from_user_on_project,205 non_existent_tenant, user['id'], role['id'])206 @test.attr(type=['negative'])207 @test.idempotent_id('7391ab4c-06f3-477a-a64a-c8e55ce89837')208 def test_list_user_roles_by_unauthorized_user(self):209 # Non-administrator user should not be authorized to list210 # a user's roles211 (user, tenant, role) = self._get_role_params()212 self.roles_client.create_user_role_on_project(tenant['id'],213 user['id'],214 role['id'])215 self.assertRaises(216 lib_exc.Forbidden,217 self.non_admin_roles_client.list_user_roles_on_project,218 tenant['id'], user['id'])219 @test.attr(type=['negative'])220 @test.idempotent_id('682adfb2-fd5f-4b0a-a9ca-322e9bebb907')221 def test_list_user_roles_request_without_token(self):222 # Request to list user's roles without a valid token should fail223 (user, tenant, role) = self._get_role_params()224 token = self.client.auth_provider.get_token()225 self.client.delete_token(token)226 try:...

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