Best Python code snippet using tempest_python
test_endpoint_group.py
Source:test_endpoint_group.py  
...54          * whether the persona can list all endpoint groups55        """56        pass57    @abc.abstractmethod58    def test_identity_update_endpoint_group(self):59        """Test identity:update_endpoint_group policy.60        This test must check:61          * whether the persona can update an endpoint group62          * whether the persona can update an endpoint group that does not63            exist64        """65        pass66    @abc.abstractmethod67    def test_identity_delete_endpoint_group(self):68        """Test identity:delete_endpoint_group policy.69        This test must check70          * whether the persona can delete an endpoint group71          * whether the persona can delete an endpoint group that does not72            exist73        """74        pass75    @abc.abstractmethod76    def test_identity_list_projects_associated_with_endpoint_group(self):77        """Test identity:list_projects_associated_with_endpoint_group policy.78        This test must check79          * whether the persona can list projects associated with an endpoint80            group81        """82        pass83    @abc.abstractmethod84    def test_identity_list_endpoints_associated_with_endpoint_group(self):85        """Test identity:list_endpoints_associated_with_endpoint_group86        This test must check87          * whether the persona can list endpoints associated with an endpoint88            group89        """90        pass91    @abc.abstractmethod92    def test_identity_get_endpoint_group_in_project(self):93        """Test identity:get_endpoint_group_in_project94        This test must check95          * whether the persona can check if an endpoint group is associated96            with a project97        """98        pass99    @abc.abstractmethod100    def test_identity_list_endpoint_groups_for_project(self):101        """Test identity:list_endpoint_groups_for_project102        This test must check103          * whether the persona can list endpoint groups associated with a104            project105        """106        pass107    @abc.abstractmethod108    def test_identity_add_endpoint_group_to_project(self):109        """Test identity:add_endpoint_group_to_project110        This test must check111          * whether the persona can allow a project to access an endpoint group112        """113        pass114    @abc.abstractmethod115    def test_identity_remove_endpoint_group_from_project(self):116        """Test identity:remove_endpoint_group_from_project117        This test must check118          * whether the persona can remove an endpoint group from a project119        """120        pass121class SystemAdminTests(122    IdentityV3RbacEndpointGroupTests, base.BaseIdentityTest):123    credentials = ['system_admin']124    def test_identity_create_endpoint_group(self):125        eg = self.do_request('create_endpoint_group', expected_status=201,126                             client=self.eg_client,127                             **self.endpoint_group())['endpoint_group']['id']128        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)129    def test_identity_get_endpoint_group(self):130        eg = self.admin_eg_client.create_endpoint_group(131            **self.endpoint_group())['endpoint_group']['id']132        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)133        # user can get an endpoint group134        self.do_request('show_endpoint_group', client=self.eg_client,135                        endpoint_group_id=eg)136        # nonexistent endpoint group gives a 404137        self.do_request('show_endpoint_group',138                        expected_status=exceptions.NotFound,139                        client=self.eg_client,140                        endpoint_group_id=data_utils.rand_uuid_hex())141    def test_identity_list_endpoint_groups(self):142        eg = self.admin_eg_client.create_endpoint_group(143            **self.endpoint_group())['endpoint_group']['id']144        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)145        resp = self.do_request('list_endpoint_groups',146                               client=self.eg_client)['endpoint_groups']147        self.assertIn(eg, [e['id'] for e in resp])148    def test_identity_update_endpoint_group(self):149        eg = self.admin_eg_client.create_endpoint_group(150            **self.endpoint_group())['endpoint_group']['id']151        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)152        # user can update an endpoint group153        self.do_request('update_endpoint_group', client=self.eg_client,154                        endpoint_group_id=eg,155                        description=data_utils.arbitrary_string())156        # nonexistent endpoint group gives a 404157        self.do_request('update_endpoint_group', client=self.eg_client,158                        expected_status=exceptions.NotFound,159                        endpoint_group_id=data_utils.rand_uuid_hex(),160                        description=data_utils.arbitrary_string())161    def test_identity_delete_endpoint_group(self):162        eg = self.admin_eg_client.create_endpoint_group(163            **self.endpoint_group())['endpoint_group']['id']164        # user can delete an endpoint group165        self.do_request('delete_endpoint_group',166                        expected_status=204,167                        client=self.eg_client,168                        endpoint_group_id=eg)169        # nonexistent endpoint group gives a 404170        self.do_request('delete_endpoint_group',171                        expected_status=exceptions.NotFound,172                        client=self.eg_client,173                        endpoint_group_id=data_utils.rand_uuid_hex())174    def test_identity_list_projects_associated_with_endpoint_group(self):175        eg = self.admin_eg_client.create_endpoint_group(176            **self.endpoint_group())['endpoint_group']['id']177        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)178        project = self.admin_client.projects_client.create_project(179            name=data_utils.rand_name('project'))['project']['id']180        self.addCleanup(self.admin_client.projects_client.delete_project,181                        project)182        self.admin_ef_client.add_endpoint_group_to_project(183            endpoint_group_id=eg, project_id=project)184        self.addCleanup(185            self.admin_ef_client.delete_endpoint_group_from_project,186            endpoint_group_id=eg, project_id=project)187        resp = self.do_request('list_projects_for_endpoint_group',188                               client=self.ef_client,189                               endpoint_group_id=eg)['projects']190        self.assertIn(project, [p['id'] for p in resp])191    def test_identity_list_endpoints_associated_with_endpoint_group(self):192        service = self.admin_client.identity_services_v3_client.create_service(193            type=data_utils.rand_name('service'))['service']['id']194        self.addCleanup(195            self.admin_client.identity_services_v3_client.delete_service,196            service)197        endpoint = self.admin_client.endpoints_v3_client.create_endpoint(198            interface='public',199            url='http://localhost/foo',200            service_id=service)['endpoint']['id']201        self.addCleanup(self.admin_client.endpoints_v3_client.delete_endpoint,202                        endpoint)203        eg = self.admin_eg_client.create_endpoint_group(204            **self.endpoint_group())['endpoint_group']['id']205        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)206        resp = self.do_request('list_endpoints_for_endpoint_group',207                               client=self.ef_client,208                               endpoint_group_id=eg)['endpoints']209        self.assertIn(endpoint, [e['id'] for e in resp])210    def test_identity_get_endpoint_group_in_project(self):211        eg = self.admin_eg_client.create_endpoint_group(212            **self.endpoint_group())['endpoint_group']['id']213        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)214        project = self.admin_client.projects_client.create_project(215            name=data_utils.rand_name('project'))['project']['id']216        self.addCleanup(self.admin_client.projects_client.delete_project,217                        project)218        self.admin_ef_client.add_endpoint_group_to_project(219            endpoint_group_id=eg, project_id=project)220        self.addCleanup(221            self.admin_ef_client.delete_endpoint_group_from_project,222            endpoint_group_id=eg, project_id=project)223        self.do_request('show_endpoint_group_for_project',224                        client=self.ef_client,225                        endpoint_group_id=eg,226                        project_id=project)227    def test_identity_list_endpoint_groups_for_project(self):228        eg = self.admin_eg_client.create_endpoint_group(229            **self.endpoint_group())['endpoint_group']['id']230        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)231        project = self.admin_client.projects_client.create_project(232            name=data_utils.rand_name('project'))['project']['id']233        self.addCleanup(self.admin_client.projects_client.delete_project,234                        project)235        self.admin_ef_client.add_endpoint_group_to_project(236            endpoint_group_id=eg, project_id=project)237        self.addCleanup(238            self.admin_ef_client.delete_endpoint_group_from_project,239            endpoint_group_id=eg, project_id=project)240        resp = self.do_request('list_endpoint_groups_for_project',241                               client=self.ef_client,242                               project_id=project)243        self.assertIn(eg, [e['id'] for e in resp['endpoint_groups']])244    def test_identity_add_endpoint_group_to_project(self):245        eg = self.admin_eg_client.create_endpoint_group(246            **self.endpoint_group())['endpoint_group']['id']247        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)248        project = self.admin_client.projects_client.create_project(249            name=data_utils.rand_name('project'))['project']['id']250        self.addCleanup(self.admin_client.projects_client.delete_project,251                        project)252        self.do_request('add_endpoint_group_to_project',253                        client=self.ef_client,254                        expected_status=204,255                        endpoint_group_id=eg,256                        project_id=project)257        self.addCleanup(258            self.admin_ef_client.delete_endpoint_group_from_project,259            endpoint_group_id=eg, project_id=project)260    def test_identity_remove_endpoint_group_from_project(self):261        eg = self.admin_eg_client.create_endpoint_group(262            **self.endpoint_group())['endpoint_group']['id']263        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)264        project = self.admin_client.projects_client.create_project(265            name=data_utils.rand_name('project'))['project']['id']266        self.addCleanup(self.admin_client.projects_client.delete_project,267                        project)268        self.admin_ef_client.add_endpoint_group_to_project(269            endpoint_group_id=eg, project_id=project)270        self.do_request('delete_endpoint_group_from_project',271                        client=self.ef_client,272                        expected_status=204,273                        endpoint_group_id=eg, project_id=project)274class SystemMemberTests(SystemAdminTests, base.BaseIdentityTest):275    credentials = ['system_member', 'system_admin']276    def test_identity_create_endpoint_group(self):277        self.do_request('create_endpoint_group',278                        expected_status=exceptions.Forbidden,279                        client=self.eg_client,280                        **self.endpoint_group())281    def test_identity_update_endpoint_group(self):282        eg = self.admin_eg_client.create_endpoint_group(283            **self.endpoint_group())['endpoint_group']['id']284        self.addCleanup(self.admin_eg_client.delete_endpoint_group, eg)285        # user can update an endpoint group286        self.do_request('update_endpoint_group', client=self.eg_client,287                        expected_status=exceptions.Forbidden,288                        endpoint_group_id=eg,289                        description=data_utils.arbitrary_string())290        # nonexistent endpoint group gives a 403291        self.do_request('update_endpoint_group', client=self.eg_client,292                        expected_status=exceptions.Forbidden,293                        endpoint_group_id=data_utils.rand_uuid_hex(),294                        description=data_utils.arbitrary_string())295    def test_identity_delete_endpoint_group(self):...test_ep_filter_groups_rbac.py
Source:test_ep_filter_groups_rbac.py  
...74            self.endpoint_group_id)['endpoint_group']75    @rbac_rule_validation.action(service="keystone",76                                 rule="identity:update_endpoint_group")77    @decorators.idempotent_id('028b9198-ec35-4bd5-8f72-e23dfb7a0c8e')78    def test_update_endpoint_group(self):79        updated_name = data_utils.rand_name(80            self.__class__.__name__ + '-EPFilterGroup')81        self.rbac_utils.switch_role(self, toggle_rbac_role=True)82        self.endpoint_groups_client.update_endpoint_group(83            self.endpoint_group_id, name=updated_name)['endpoint_group']84    @rbac_rule_validation.action(service="keystone",85                                 rule="identity:delete_endpoint_group")86    @decorators.idempotent_id('88cc105e-70d9-48ac-927e-200ef41e070c')87    def test_delete_endpoint_group(self):88        endpoint_group_id = self._create_endpoint_group(ignore_not_found=True)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!!
