Best Python code snippet using tempest_python
test_policy_association.py
Source:test_policy_association.py
...173 'show_policy_association_for_endpoint',174 expected_status=204,175 policy_id=self.policy_id, endpoint_id=self.endpoint_id)176 def test_identity_check_policy_association_for_service(self):177 self.admin_policies_client.update_policy_association_for_service(178 policy_id=self.policy_id, service_id=self.service_id)179 self.addCleanup(180 self.admin_policies_client.delete_policy_association_for_service,181 policy_id=self.policy_id, service_id=self.service_id)182 self.do_request(183 'show_policy_association_for_service',184 expected_status=204,185 policy_id=self.policy_id, service_id=self.service_id)186 def test_identity_check_policy_association_for_region_and_service(self):187 update_fn = getattr(188 self.admin_policies_client,189 'update_policy_association_for_region_and_service'190 )191 update_fn(policy_id=self.policy_id,192 service_id=self.service_id,193 region_id=self.region_id)194 delete_fn = getattr(195 self.admin_policies_client,196 'delete_policy_association_for_region_and_service'197 )198 self.addCleanup(delete_fn,199 policy_id=self.policy_id,200 service_id=self.service_id,201 region_id=self.region_id)202 self.do_request(203 'show_policy_association_for_region_and_service',204 expected_status=204,205 policy_id=self.policy_id,206 service_id=self.service_id,207 region_id=self.region_id)208 def test_identity_get_policy_for_endpoint(self):209 self.admin_policies_client.update_policy_association_for_endpoint(210 policy_id=self.policy_id, endpoint_id=self.endpoint_id)211 self.addCleanup(212 self.admin_policies_client.delete_policy_association_for_endpoint,213 policy_id=self.policy_id, endpoint_id=self.endpoint_id)214 self.do_request(215 'show_policy_for_endpoint',216 expected_status=200,217 endpoint_id=self.endpoint_id)218 def test_identity_list_endpoints_for_policy(self):219 self.admin_policies_client.update_policy_association_for_endpoint(220 policy_id=self.policy_id, endpoint_id=self.endpoint_id)221 self.addCleanup(222 self.admin_policies_client.delete_policy_association_for_endpoint,223 policy_id=self.policy_id, endpoint_id=self.endpoint_id)224 self.do_request(225 'list_endpoints_for_policy',226 expected_status=200,227 policy_id=self.policy_id)228 def test_identity_delete_policy_association_for_endpoint(self):229 self.admin_policies_client.update_policy_association_for_endpoint(230 policy_id=self.policy_id, endpoint_id=self.endpoint_id)231 self.do_request(232 'delete_policy_association_for_endpoint',233 expected_status=204,234 policy_id=self.policy_id, endpoint_id=self.endpoint_id)235 def test_identity_delete_policy_association_for_service(self):236 self.admin_policies_client.update_policy_association_for_service(237 policy_id=self.policy_id, service_id=self.service_id)238 self.do_request(239 'delete_policy_association_for_service',240 expected_status=204,241 policy_id=self.policy_id, service_id=self.service_id)242 def test_identity_delete_policy_association_for_region_and_service(self):243 update_fn = getattr(244 self.admin_policies_client,245 'update_policy_association_for_region_and_service'246 )247 update_fn(policy_id=self.policy_id,248 service_id=self.service_id,249 region_id=self.region_id)250 self.do_request(251 'delete_policy_association_for_region_and_service',252 expected_status=204,253 policy_id=self.policy_id,254 service_id=self.service_id,255 region_id=self.region_id)256class SystemMemberTests(SystemAdminTests, base.BaseIdentityTest):257 credentials = ['system_member', 'system_admin']258 def test_identity_create_policy_association_for_endpoint(self):259 self.do_request(260 'update_policy_association_for_endpoint',261 expected_status=exceptions.Forbidden,262 policy_id=self.policy_id, endpoint_id=self.endpoint_id)263 def test_identity_create_policy_association_for_service(self):264 self.do_request(265 'update_policy_association_for_service',266 expected_status=exceptions.Forbidden,267 policy_id=self.policy_id, service_id=self.service_id)268 def test_identity_create_policy_association_for_region_and_service(self):269 self.do_request(270 'update_policy_association_for_region_and_service',271 expected_status=exceptions.Forbidden,272 policy_id=self.policy_id, service_id=self.service_id,273 region_id=self.region_id)274 def test_identity_delete_policy_association_for_endpoint(self):275 self.admin_policies_client.update_policy_association_for_endpoint(276 policy_id=self.policy_id, endpoint_id=self.endpoint_id)277 self.addCleanup(278 self.admin_policies_client.delete_policy_association_for_endpoint,279 policy_id=self.policy_id, endpoint_id=self.endpoint_id)280 self.do_request(281 'delete_policy_association_for_endpoint',282 expected_status=exceptions.Forbidden,283 policy_id=self.policy_id, endpoint_id=self.endpoint_id)284 def test_identity_delete_policy_association_for_service(self):285 self.admin_policies_client.update_policy_association_for_service(286 policy_id=self.policy_id, service_id=self.service_id)287 self.addCleanup(288 self.admin_policies_client.delete_policy_association_for_service,289 policy_id=self.policy_id, service_id=self.service_id)290 self.do_request(291 'delete_policy_association_for_service',292 expected_status=exceptions.Forbidden,293 policy_id=self.policy_id, service_id=self.service_id)294 def test_identity_delete_policy_association_for_region_and_service(self):295 update_fn = getattr(296 self.admin_policies_client,297 'update_policy_association_for_region_and_service'298 )299 update_fn(policy_id=self.policy_id,300 service_id=self.service_id,301 region_id=self.region_id)302 delete_fn = getattr(303 self.admin_policies_client,304 'delete_policy_association_for_region_and_service'305 )306 self.addCleanup(delete_fn,307 policy_id=self.policy_id,308 service_id=self.service_id,309 region_id=self.region_id)310 self.do_request(311 'delete_policy_association_for_region_and_service',312 expected_status=exceptions.Forbidden,313 policy_id=self.policy_id,314 service_id=self.service_id,315 region_id=self.region_id)316class SystemReaderTests(SystemMemberTests):317 credentials = ['system_reader', 'system_admin']318class DomainAdminTests(SystemReaderTests, base.BaseIdentityTest):319 credentials = ['domain_admin', 'system_admin']320 def test_identity_check_policy_association_for_endpoint(self):321 self.admin_policies_client.update_policy_association_for_endpoint(322 policy_id=self.policy_id, endpoint_id=self.endpoint_id)323 self.addCleanup(324 self.admin_policies_client.delete_policy_association_for_endpoint,325 policy_id=self.policy_id, endpoint_id=self.endpoint_id)326 self.do_request(327 'show_policy_association_for_endpoint',328 expected_status=exceptions.Forbidden,329 policy_id=self.policy_id, endpoint_id=self.endpoint_id)330 def test_identity_check_policy_association_for_service(self):331 self.admin_policies_client.update_policy_association_for_service(332 policy_id=self.policy_id, service_id=self.service_id)333 self.addCleanup(334 self.admin_policies_client.delete_policy_association_for_service,335 policy_id=self.policy_id, service_id=self.service_id)336 self.do_request(337 'show_policy_association_for_service',338 expected_status=exceptions.Forbidden,339 policy_id=self.policy_id, service_id=self.service_id)340 def test_identity_check_policy_association_for_region_and_service(self):341 update_fn = getattr(342 self.admin_policies_client,343 'update_policy_association_for_region_and_service'344 )345 update_fn(policy_id=self.policy_id,...
test_policy_association_rbac.py
Source:test_policy_association_rbac.py
...30 self.addCleanup(31 test_utils.call_and_ignore_notfound_exc,32 self.policies_client.delete_policy_association_for_endpoint,33 policy_id, endpoint_id)34 def _update_policy_association_for_service(self, policy_id, service_id):35 self.policies_client.update_policy_association_for_service(36 policy_id, service_id)37 self.addCleanup(38 test_utils.call_and_ignore_notfound_exc,39 self.policies_client.delete_policy_association_for_service,40 policy_id, service_id)41 def _update_policy_association_for_region_and_service(42 self, policy_id, service_id, region_id):43 self.policies_client.update_policy_association_for_region_and_service(44 policy_id, service_id, region_id)45 self.addCleanup(46 test_utils.call_and_ignore_notfound_exc,47 self.policies_client.48 delete_policy_association_for_region_and_service,49 policy_id, service_id, region_id)50 @rbac_rule_validation.action(51 service="keystone",52 rules=["identity:create_policy_association_for_endpoint"])53 @decorators.idempotent_id('1b3f4f62-4f4a-4d27-be27-9a113058597f')54 def test_update_policy_association_for_endpoint(self):55 with self.override_role():56 self._update_policy_association_for_endpoint(57 self.policy_id, self.endpoint_id)58 @rbac_rule_validation.action(59 service="keystone",60 rules=["identity:check_policy_association_for_endpoint"])61 @decorators.idempotent_id('25ce8c89-e751-465c-8d35-52bacd774beb')62 def test_show_policy_association_for_endpoint(self):63 self._update_policy_association_for_endpoint(64 self.policy_id, self.endpoint_id)65 with self.override_role():66 self.policies_client.show_policy_association_for_endpoint(67 self.policy_id, self.endpoint_id)68 @rbac_rule_validation.action(69 service="keystone",70 rules=["identity:delete_policy_association_for_endpoint"])71 @decorators.idempotent_id('95cad2d8-bcd0-4c4e-a8f7-cc80601e43a1')72 def test_delete_policy_association_for_endpoint(self):73 self._update_policy_association_for_endpoint(74 self.policy_id, self.endpoint_id)75 with self.override_role():76 self.policies_client.delete_policy_association_for_endpoint(77 self.policy_id, self.endpoint_id)78 @rbac_rule_validation.action(79 service="keystone",80 rules=["identity:create_policy_association_for_service"])81 @decorators.idempotent_id('57fb80fe-6ce2-4995-b710-4692b3fc3cdc')82 def test_update_policy_association_for_service(self):83 with self.override_role():84 self._update_policy_association_for_service(85 self.policy_id, self.service_id)86 @rbac_rule_validation.action(87 service="keystone",88 rules=["identity:check_policy_association_for_service"])89 @decorators.idempotent_id('5cbe285f-4888-4f98-978f-30210ff28b74')90 def test_show_policy_association_for_service(self):91 self._update_policy_association_for_service(92 self.policy_id, self.service_id)93 with self.override_role():94 self.policies_client.show_policy_association_for_service(95 self.policy_id, self.service_id)96 @rbac_rule_validation.action(97 service="keystone",98 rules=["identity:delete_policy_association_for_service"])99 @decorators.idempotent_id('f754455c-02a4-4fb6-8c73-64ef453f955f')100 def test_delete_policy_association_for_service(self):101 self._update_policy_association_for_service(102 self.policy_id, self.service_id)103 with self.override_role():104 self.policies_client.delete_policy_association_for_service(105 self.policy_id, self.service_id)106 @rbac_rule_validation.action(107 service="keystone",108 rules=["identity:create_policy_association_for_region_and_service"])109 @decorators.idempotent_id('54d2a93e-c84d-4079-8ea9-2fb227c262a1')110 def test_update_policy_association_for_region_and_service(self):111 with self.override_role():112 self._update_policy_association_for_region_and_service(113 self.policy_id, self.service_id, self.region_id)114 @rbac_rule_validation.action(115 service="keystone",...
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!!