Best Python code snippet using tempest_python
test_policy_association.py
Source:test_policy_association.py
...108 * whether the persona can list endpoints for a policy109 """110 pass111 @abc.abstractmethod112 def test_identity_delete_policy_association_for_endpoint(self):113 """Test identity:delete_policy_association_for_endpoint policy.114 This test must check115 * whether the persona can delete a policy association for an endpoint116 """117 pass118 @abc.abstractmethod119 def test_identity_delete_policy_association_for_service(self):120 """Test identity:delete_policy_association_for_service policy.121 This test must check122 * whether the persona can delete a policy association for a service123 """124 pass125 @abc.abstractmethod126 def test_identity_delete_policy_association_for_region_and_service(self):127 """Test identity:delete_policy_association_for_region_and_service policy.128 This test must check129 * whether the persona can delete a policy association for a region130 and service131 """132 pass133class SystemAdminTests(134 IdentityV3RbacPolicyAssociationTests, base.BaseIdentityTest):135 credentials = ['system_admin']136 def test_identity_create_policy_association_for_endpoint(self):137 self.do_request(138 'update_policy_association_for_endpoint',139 expected_status=204,140 policy_id=self.policy_id, endpoint_id=self.endpoint_id)141 self.addCleanup(142 self.admin_policies_client.delete_policy_association_for_endpoint,143 policy_id=self.policy_id, endpoint_id=self.endpoint_id)144 def test_identity_create_policy_association_for_service(self):145 self.do_request(146 'update_policy_association_for_service',147 expected_status=204,148 policy_id=self.policy_id, service_id=self.service_id)149 self.addCleanup(150 self.admin_policies_client.delete_policy_association_for_service,151 policy_id=self.policy_id, service_id=self.service_id)152 def test_identity_create_policy_association_for_region_and_service(self):153 self.do_request(154 'update_policy_association_for_region_and_service',155 expected_status=204,156 policy_id=self.policy_id, service_id=self.service_id,157 region_id=self.region_id)158 delete_fn = getattr(159 self.admin_policies_client,160 'delete_policy_association_for_region_and_service'161 )162 self.addCleanup(delete_fn,163 policy_id=self.policy_id,164 service_id=self.service_id,165 region_id=self.region_id)166 def test_identity_check_policy_association_for_endpoint(self):167 self.admin_policies_client.update_policy_association_for_endpoint(168 policy_id=self.policy_id, endpoint_id=self.endpoint_id)169 self.addCleanup(170 self.admin_policies_client.delete_policy_association_for_endpoint,171 policy_id=self.policy_id, endpoint_id=self.endpoint_id)172 self.do_request(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,...
test_policy_association_rbac.py
Source:test_policy_association_rbac.py
...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):...
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!!