def _create_dummy_endpoint(self, add_clean_up=True): region_id = data_utils.rand_name('TestRegion') service_name = self._create_dummy_service() public_url = data_utils.rand_url() admin_url = data_utils.rand_url() internal_url = data_utils.rand_url() raw_output = self.openstack( 'endpoint create ' '--publicurl %(publicurl)s ' '--adminurl %(adminurl)s ' '--internalurl %(internalurl)s ' '--region %(region)s ' '%(service)s' % { 'publicurl': public_url, 'adminurl': admin_url, 'internalurl': internal_url, 'region': region_id, 'service': service_name }) endpoint = self.parse_show_as_object(raw_output) if add_clean_up: self.addCleanup(self.openstack, 'endpoint delete %s' % endpoint['id']) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ENDPOINT_FIELDS) return endpoint['id']
def _create_dummy_endpoint(self, add_clean_up=True): region_id = data_utils.rand_name('TestRegion') service_name = self._create_dummy_service() public_url = data_utils.rand_url() admin_url = data_utils.rand_url() internal_url = data_utils.rand_url() raw_output = self.openstack( 'endpoint create ' '--publicurl %(publicurl)s ' '--adminurl %(adminurl)s ' '--internalurl %(internalurl)s ' '--region %(region)s ' '%(service)s' % {'publicurl': public_url, 'adminurl': admin_url, 'internalurl': internal_url, 'region': region_id, 'service': service_name}) endpoint = self.parse_show_as_object(raw_output) if add_clean_up: self.addCleanup( self.openstack, 'endpoint delete %s' % endpoint['id']) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ENDPOINT_FIELDS) return endpoint['id']
def test_update_endpoint(self): # Creating an endpoint so as to check update endpoint # with new values region1 = data_utils.rand_name('region') url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = ( self.client.create_endpoint(service_id=self.service_ids[0], interface=interface1, url=url1, region=region1, enabled=True)['endpoint']) self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) # Creating service so as update endpoint with new service ID s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service2 = self._create_service(s_name=s_name, s_type=s_type, s_description=s_description) # Updating endpoint with new values region2 = data_utils.rand_name('region') url2 = data_utils.rand_url() interface2 = 'internal' endpoint = self.client.update_endpoint(endpoint_for_update['id'], service_id=service2['id'], interface=interface2, url=url2, region=region2, enabled=False)['endpoint'] # Asserting if the attributes of endpoint are updated self.assertEqual(service2['id'], endpoint['service_id']) self.assertEqual(interface2, endpoint['interface']) self.assertEqual(url2, endpoint['url']) self.assertEqual(region2, endpoint['region']) self.assertEqual(False, endpoint['enabled'])
def test_identity_create_service_provider(self): sp_id = self.do_request( 'create_service_provider', expected_status=201, sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())['service_provider']['id'] self.addCleanup(self.admin_sp_client.delete_service_provider, sp_id)
def test_identity_list_service_providers(self): sp_id = self.admin_sp_client.create_service_provider( sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())['service_provider']['id'] self.addCleanup(self.admin_sp_client.delete_service_provider, sp_id) resp = self.do_request('list_service_providers') self.assertIn(sp_id, [i['id'] for i in resp['service_providers']])
def test_identity_list_service_providers(self): sp_id = self.admin_sp_client.create_service_provider( sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())['service_provider']['id'] self.addCleanup(self.admin_sp_client.delete_service_provider, sp_id) self.do_request('list_service_providers', expected_status=exceptions.Forbidden)
def test_identity_get_service_provider(self): sp_id = self.admin_sp_client.create_service_provider( sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())['service_provider']['id'] self.addCleanup(self.admin_sp_client.delete_service_provider, sp_id) self.do_request('show_service_provider', sp_id=sp_id) # user gets a 404 for nonexistent sp self.do_request('show_service_provider', expected_status=exceptions.NotFound, sp_id=data_utils.rand_uuid_hex())
def sp_ref(enabled=None, relay_state_prefix=None): ref = { 'auth_url': data_utils.rand_url(), 'description': data_utils.rand_uuid_hex(), 'sp_url': data_utils.rand_url(), } if enabled: ref['enabled'] = enabled if relay_state_prefix: ref['relay_state_prefix'] = relay_state_prefix return ref
def test_update_endpoint(self): """Test updating keystone endpoint""" # NOTE(zhufl) Service2 should be created before endpoint_for_update # is created, because Service2 must be deleted after # endpoint_for_update is deleted, otherwise we will get a 404 error # when deleting endpoint_for_update if endpoint's service is deleted. # Creating service for updating endpoint with new service ID s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service2 = self._create_service(s_name=s_name, s_type=s_type, s_description=s_description) self.addCleanup(self.services_client.delete_service, service2['id']) # Creating an endpoint so as to check update endpoint with new values region1_name = data_utils.rand_name('region') url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = (self.client.create_endpoint( service_id=self.service_ids[0], interface=interface1, url=url1, region=region1_name, enabled=True)['endpoint']) region1 = self.regions_client.show_region(region1_name)['region'] self.addCleanup(self.regions_client.delete_region, region1['id']) # Updating endpoint with new values region2_name = data_utils.rand_name('region') url2 = data_utils.rand_url() interface2 = 'internal' endpoint = self.client.update_endpoint(endpoint_for_update['id'], service_id=service2['id'], interface=interface2, url=url2, region=region2_name, enabled=False)['endpoint'] region2 = self.regions_client.show_region(region2_name)['region'] self.addCleanup(self.regions_client.delete_region, region2['id']) self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) # Asserting if the attributes of endpoint are updated self.assertEqual(service2['id'], endpoint['service_id']) self.assertEqual(interface2, endpoint['interface']) self.assertEqual(url2, endpoint['url']) self.assertEqual(region2_name, endpoint['region']) self.assertEqual(False, endpoint['enabled'])
def test_identity_update_service_provider(self): sp_id = self.admin_sp_client.create_service_provider( sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())['service_provider']['id'] self.addCleanup(self.admin_sp_client.delete_service_provider, sp_id) self.do_request('update_service_provider', expected_status=exceptions.Forbidden, sp_id=sp_id, description=data_utils.arbitrary_string()) # user gets a 403 for nonexistent sp self.do_request('update_service_provider', expected_status=exceptions.Forbidden, sp_id=data_utils.rand_uuid_hex(), description=data_utils.arbitrary_string())
def setup_test_endpoint(cls, service=None): """Creates a service and an endpoint for test.""" interface = 'public' url = data_utils.rand_url() region_name = data_utils.rand_name( cls.__name__ + '-region') # Endpoint creation requires a service if service is None: service = cls.setup_test_service() params = { 'service_id': service['id'], 'region': region_name, 'interface': interface } if cls.identity_version == 'v2': params['publicurl'] = url elif cls.identity_version == 'v3': params['url'] = url endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint'] cls.addClassResourceCleanup( test_utils.call_and_ignore_notfound_exc, cls.endpoints_client.delete_endpoint, endpoint['id']) return endpoint
def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service_data = cls.services_client.create_service( name=s_name, type=s_type, description=s_description)['OS-KSADM:service'] cls.addClassResourceCleanup(cls.services_client.delete_service, service_data['id']) cls.service_id = service_data['id'] # Create endpoints so as to use for LIST and GET test cases cls.setup_endpoints = list() for _ in range(2): region = data_utils.rand_name('region') url = data_utils.rand_url() endpoint = cls.endpoints_client.create_endpoint( service_id=cls.service_id, region=region, publicurl=url, adminurl=url, internalurl=url)['endpoint'] cls.addClassResourceCleanup(cls.endpoints_client.delete_endpoint, endpoint['id']) # list_endpoints() will return 'enabled' field endpoint['enabled'] = True cls.setup_endpoints.append(endpoint)
def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() cls.service_ids = list() # Create endpoints so as to use for LIST and GET test cases interfaces = ['public', 'internal'] cls.setup_endpoint_ids = list() for i in range(2): service = cls._create_service() cls.service_ids.append(service['id']) cls.addClassResourceCleanup(cls.services_client.delete_service, service['id']) region_name = data_utils.rand_name('region') url = data_utils.rand_url() endpoint = cls.client.create_endpoint( service_id=cls.service_ids[i], interface=interfaces[i], url=url, region=region_name, enabled=True)['endpoint'] region = cls.regions_client.show_region(region_name)['region'] cls.addClassResourceCleanup(cls.regions_client.delete_region, region['id']) cls.addClassResourceCleanup(cls.client.delete_endpoint, endpoint['id']) cls.setup_endpoint_ids.append(endpoint['id'])
def setup_test_endpoint(cls, service=None): """Creates a service and an endpoint for test.""" interface = 'public' url = data_utils.rand_url() region_name = data_utils.rand_name(cls.__name__ + '-region') # Endpoint creation requires a service if service is None: service = cls.setup_test_service() params = { 'service_id': service['id'], 'region': region_name, 'interface': interface } if cls.identity_version == 'v2': params['publicurl'] = url elif cls.identity_version == 'v3': params['url'] = url else: LOG.debug("Keystone version is invalid." " Please enter a valid version number.") raise KeyError endpoint = cls.endpoints_client.create_endpoint(**params)['endpoint'] cls.endpoints.append(endpoint) return endpoint
def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() cls.service_ids = list() s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service_data = cls.services_client.create_service( name=s_name, type=s_type, description=s_description)['OS-KSADM:service'] cls.service_id = service_data['id'] cls.service_ids.append(cls.service_id) # Create endpoints so as to use for LIST and GET test cases cls.setup_endpoints = list() for _ in range(2): region = data_utils.rand_name('region') url = data_utils.rand_url() endpoint = cls.endpoints_client.create_endpoint( service_id=cls.service_id, region=region, publicurl=url, adminurl=url, internalurl=url)['endpoint'] # list_endpoints() will return 'enabled' field endpoint['enabled'] = True cls.setup_endpoints.append(endpoint)
def test_update_endpoint(self): endpoint = self.setup_test_endpoint() new_url = data_utils.rand_url() with self.rbac_utils.override_role(self): self.endpoints_client.update_endpoint( endpoint["id"], url=new_url)
def test_create_with_enabled_True(self): # Enabled should be a boolean, not a string like 'True' interface = 'public' url = data_utils.rand_url() region = data_utils.rand_name('region') self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint, service_id=self.service_id, interface=interface, url=url, region=region, enabled='True')
def test_create_with_enabled_False(self): """Test creating endpoint with invalid enabled value 'False' Enabled should be a boolean, not a string like 'False' """ interface = 'public' url = data_utils.rand_url() region = data_utils.rand_name('region') self.assertRaises(lib_exc.BadRequest, self.client.create_endpoint, service_id=self.service_id, interface=interface, url=url, region=region, enabled='False')
def test_update_endpoint(self): # NOTE(zhufl) Service2 should be created before endpoint_for_update # is created, because Service2 must be deleted after # endpoint_for_update is deleted, otherwise we will get a 404 error # when deleting endpoint_for_update if endpoint's service is deleted. # Creating service for updating endpoint with new service ID s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service2 = self._create_service(s_name=s_name, s_type=s_type, s_description=s_description) self.addCleanup(self.services_client.delete_service, service2['id']) # Creating an endpoint so as to check update endpoint with new values region1 = data_utils.rand_name('region') url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = ( self.client.create_endpoint(service_id=self.service_ids[0], interface=interface1, url=url1, region=region1, enabled=True)['endpoint']) self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) # Updating endpoint with new values region2 = data_utils.rand_name('region') url2 = data_utils.rand_url() interface2 = 'internal' endpoint = self.client.update_endpoint(endpoint_for_update['id'], service_id=service2['id'], interface=interface2, url=url2, region=region2, enabled=False)['endpoint'] # Asserting if the attributes of endpoint are updated self.assertEqual(service2['id'], endpoint['service_id']) self.assertEqual(interface2, endpoint['interface']) self.assertEqual(url2, endpoint['url']) self.assertEqual(region2, endpoint['region']) self.assertEqual(False, endpoint['enabled'])
def test_update_endpoint(self): # Creating an endpoint so as to check update endpoint # with new values region1 = data_utils.rand_name('region') url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = (self.client.create_endpoint( service_id=self.service_id, interface=interface1, url=url1, region=region1, enabled=True)['endpoint']) self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) # Creating service so as update endpoint with new service ID s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service2 = (self.services_client.create_service( name=s_name, type=s_type, description=s_description)) service2 = service2['service'] self.service_ids.append(service2['id']) # Updating endpoint with new values region2 = data_utils.rand_name('region') url2 = data_utils.rand_url() interface2 = 'internal' endpoint = self.client.update_endpoint(endpoint_for_update['id'], service_id=service2['id'], interface=interface2, url=url2, region=region2, enabled=False)['endpoint'] # Asserting if the attributes of endpoint are updated self.assertEqual(service2['id'], endpoint['service_id']) self.assertEqual(interface2, endpoint['interface']) self.assertEqual(url2, endpoint['url']) self.assertEqual(region2, endpoint['region']) self.assertEqual(False, endpoint['enabled'])
def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() cls.service_ids = list() # Create endpoints so as to use for LIST and GET test cases interfaces = ['public', 'internal'] cls.setup_endpoint_ids = list() for i in range(2): cls._create_service() region = data_utils.rand_name('region') url = data_utils.rand_url() endpoint = cls.client.create_endpoint( service_id=cls.service_ids[i], interface=interfaces[i], url=url, region=region, enabled=True)['endpoint'] cls.setup_endpoint_ids.append(endpoint['id'])
def _assert_update_raises_bad_request(self, enabled): # Create an endpoint region1 = data_utils.rand_name('region') url1 = data_utils.rand_url() interface1 = 'public' endpoint_for_update = ( self.client.create_endpoint(service_id=self.service_id, interface=interface1, url=url1, region=region1, enabled=True)['endpoint']) self.addCleanup(self.client.delete_endpoint, endpoint_for_update['id']) self.assertRaises(lib_exc.BadRequest, self.client.update_endpoint, endpoint_for_update['id'], enabled=enabled)
def test_endpoint_set(self): endpoint_id = self._create_dummy_endpoint() new_endpoint_url = data_utils.rand_url() raw_output = self.openstack( "endpoint set " "--interface %(interface)s " "--url %(url)s " "--disable " "%(endpoint_id)s" % {"interface": "admin", "url": new_endpoint_url, "endpoint_id": endpoint_id} ) self.assertEqual(0, len(raw_output)) raw_output = self.openstack("endpoint show %s" % endpoint_id) endpoint = self.parse_show_as_object(raw_output) self.assertEqual("admin", endpoint["interface"]) self.assertEqual(new_endpoint_url, endpoint["url"]) self.assertEqual("False", endpoint["enabled"])
def test_endpoint_set(self): endpoint_id = self._create_dummy_endpoint() new_endpoint_url = data_utils.rand_url() raw_output = self.openstack( 'endpoint set ' '--interface %(interface)s ' '--url %(url)s ' '--disable ' '%(endpoint_id)s' % {'interface': 'admin', 'url': new_endpoint_url, 'endpoint_id': endpoint_id}) self.assertEqual(0, len(raw_output)) raw_output = self.openstack('endpoint show %s' % endpoint_id) endpoint = self.parse_show_as_object(raw_output) self.assertEqual('admin', endpoint['interface']) self.assertEqual(new_endpoint_url, endpoint['url']) self.assertEqual('False', endpoint['enabled'])
def test_endpoint_set(self): endpoint_id = self._create_dummy_endpoint() new_endpoint_url = data_utils.rand_url() raw_output = self.openstack( 'endpoint set ' '--interface %(interface)s ' '--url %(url)s ' '--disable ' '%(endpoint_id)s' % { 'interface': 'admin', 'url': new_endpoint_url, 'endpoint_id': endpoint_id }) self.assertEqual(0, len(raw_output)) raw_output = self.openstack('endpoint show %s' % endpoint_id) endpoint = self.parse_show_as_object(raw_output) self.assertEqual('admin', endpoint['interface']) self.assertEqual(new_endpoint_url, endpoint['url']) self.assertEqual('False', endpoint['enabled'])
def test_create_update_and_delete_domain_config(self): domain, created_config = self._create_domain_and_config( self.custom_config) new_config = created_config new_config['ldap']['url'] = data_utils.rand_url() # Check that the altered configuration is reflected in updated_config. updated_config = self.client.update_domain_config( domain['id'], **new_config)['config'] self.assertEqual(new_config, updated_config) # Check that showing the domain config shows the altered configuration. retrieved_config = self.client.show_domain_config(domain['id'])[ 'config'] self.assertEqual(new_config, retrieved_config) # Check that deleting a configuration works. self.client.delete_domain_config(domain['id']) self.assertRaises(lib_exc.NotFound, self.client.show_domain_config, domain['id'])
def test_create_update_and_delete_domain_config(self): domain, created_config = self._create_domain_and_config( self.custom_config) new_config = created_config new_config['ldap']['url'] = data_utils.rand_url() # Check that the altered configuration is reflected in updated_config. updated_config = self.client.update_domain_config( domain['id'], **new_config)['config'] self.assertEqual(new_config, updated_config) # Check that showing the domain config shows the altered configuration. retrieved_config = self.client.show_domain_config( domain['id'])['config'] self.assertEqual(new_config, retrieved_config) # Check that deleting a configuration works. self.client.delete_domain_config(domain['id']) self.assertRaises(lib_exc.NotFound, self.client.show_domain_config, domain['id'])
def test_create_list_show_delete_endpoint(self): """Test creating, listing, showing and deleting keystone endpoint""" region_name = data_utils.rand_name('region') url = data_utils.rand_url() interface = 'public' endpoint = self.client.create_endpoint(service_id=self.service_ids[0], interface=interface, url=url, region=region_name, enabled=True)['endpoint'] region = self.regions_client.show_region(region_name)['region'] self.addCleanup(self.regions_client.delete_region, region['id']) self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.client.delete_endpoint, endpoint['id']) # Asserting Create Endpoint response body self.assertEqual(region_name, endpoint['region']) self.assertEqual(url, endpoint['url']) # Checking if created endpoint is present in the list of endpoints fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertIn(endpoint['id'], fetched_endpoints_id) # Show endpoint fetched_endpoint = (self.client.show_endpoint( endpoint['id'])['endpoint']) # Asserting if the attributes of endpoint are the same self.assertEqual(self.service_ids[0], fetched_endpoint['service_id']) self.assertEqual(interface, fetched_endpoint['interface']) self.assertEqual(url, fetched_endpoint['url']) self.assertEqual(region_name, fetched_endpoint['region']) self.assertEqual(True, fetched_endpoint['enabled']) # Deleting the endpoint created in this method self.client.delete_endpoint(endpoint['id']) # Checking whether endpoint is deleted successfully fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertNotIn(endpoint['id'], fetched_endpoints_id)
def _create_dummy_endpoint(self, interface='public', add_clean_up=True): region_id = self._create_dummy_region() service_name = self._create_dummy_service() endpoint_url = data_utils.rand_url() raw_output = self.openstack( 'endpoint create ' '--region %(region)s ' '--enable ' '%(service)s ' '%(interface)s ' '%(url)s' % {'region': region_id, 'service': service_name, 'interface': interface, 'url': endpoint_url}) endpoint = self.parse_show_as_object(raw_output) if add_clean_up: self.addCleanup( self.openstack, 'endpoint delete %s' % endpoint['id']) items = self.parse_show(raw_output) self.assert_show_fields(items, self.ENDPOINT_FIELDS) return endpoint['id']
def test_create_list_show_delete_endpoint(self): region = data_utils.rand_name('region') url = data_utils.rand_url() interface = 'public' endpoint = self.client.create_endpoint(service_id=self.service_id, interface=interface, url=url, region=region, enabled=True)['endpoint'] self.setup_endpoints.append(endpoint) # Asserting Create Endpoint response body self.assertIn('id', endpoint) self.assertEqual(region, endpoint['region']) self.assertEqual(url, endpoint['url']) # Checking if created endpoint is present in the list of endpoints fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertIn(endpoint['id'], fetched_endpoints_id) # Show endpoint fetched_endpoint = (self.client.show_endpoint( endpoint['id'])['endpoint']) # Asserting if the attributes of endpoint are the same self.assertEqual(self.service_id, fetched_endpoint['service_id']) self.assertEqual(interface, fetched_endpoint['interface']) self.assertEqual(url, fetched_endpoint['url']) self.assertEqual(region, fetched_endpoint['region']) self.assertEqual(True, fetched_endpoint['enabled']) # Deleting the endpoint created in this method self.client.delete_endpoint(endpoint['id']) self.setup_endpoints.remove(endpoint) # Checking whether endpoint is deleted successfully fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertNotIn(endpoint['id'], fetched_endpoints_id)
def resource_setup(cls): super(EndPointsTestJSON, cls).resource_setup() cls.service_ids = list() s_name = data_utils.rand_name('service') s_type = data_utils.rand_name('type') s_description = data_utils.rand_name('description') service_data = (cls.services_client.create_service( name=s_name, type=s_type, description=s_description)) cls.service_id = service_data['service']['id'] cls.service_ids.append(cls.service_id) # Create endpoints so as to use for LIST and GET test cases cls.setup_endpoints = list() for _ in range(2): region = data_utils.rand_name('region') url = data_utils.rand_url() interface = 'public' endpoint = cls.client.create_endpoint(service_id=cls.service_id, interface=interface, url=url, region=region, enabled=True)['endpoint'] cls.setup_endpoints.append(endpoint)
def test_create_list_delete_endpoint(self): region = data_utils.rand_name('region') url = data_utils.rand_url() endpoint = self.endpoints_client.create_endpoint( service_id=self.service_id, region=region, publicurl=url, adminurl=url, internalurl=url)['endpoint'] # Asserting Create Endpoint response body self.assertIn('id', endpoint) self.assertEqual(region, endpoint['region']) self.assertEqual(url, endpoint['publicurl']) # Checking if created endpoint is present in the list of endpoints fetched_endpoints = self.endpoints_client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertIn(endpoint['id'], fetched_endpoints_id) # Deleting the endpoint created in this method self.endpoints_client.delete_endpoint(endpoint['id']) # Checking whether endpoint is deleted successfully fetched_endpoints = self.endpoints_client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertNotIn(endpoint['id'], fetched_endpoints_id)
def test_create_list_show_delete_endpoint(self): region = data_utils.rand_name('region') url = data_utils.rand_url() interface = 'public' endpoint = self.client.create_endpoint(service_id=self.service_ids[0], interface=interface, url=url, region=region, enabled=True)['endpoint'] self.setup_endpoint_ids.append(endpoint['id']) # Asserting Create Endpoint response body self.assertEqual(region, endpoint['region']) self.assertEqual(url, endpoint['url']) # Checking if created endpoint is present in the list of endpoints fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertIn(endpoint['id'], fetched_endpoints_id) # Show endpoint fetched_endpoint = ( self.client.show_endpoint(endpoint['id'])['endpoint']) # Asserting if the attributes of endpoint are the same self.assertEqual(self.service_ids[0], fetched_endpoint['service_id']) self.assertEqual(interface, fetched_endpoint['interface']) self.assertEqual(url, fetched_endpoint['url']) self.assertEqual(region, fetched_endpoint['region']) self.assertEqual(True, fetched_endpoint['enabled']) # Deleting the endpoint created in this method self.client.delete_endpoint(endpoint['id']) self.setup_endpoint_ids.remove(endpoint['id']) # Checking whether endpoint is deleted successfully fetched_endpoints = self.client.list_endpoints()['endpoints'] fetched_endpoints_id = [e['id'] for e in fetched_endpoints] self.assertNotIn(endpoint['id'], fetched_endpoints_id)
def test_update_domain_config(self): updated_config = {'ldap': {'url': data_utils.rand_url()}} with self.rbac_utils.override_role(self): self.domain_config_client.update_domain_config( self.domain_id, **updated_config)
def test_rand_url(self): actual = data_utils.rand_url() self.assertIsInstance(actual, str) self.assertRegex(actual, "^https://url-[0-9]*\.com$") actual2 = data_utils.rand_url() self.assertNotEqual(actual, actual2)
def test_update_domain_config(self): updated_config = {'ldap': {'url': data_utils.rand_url()}} self.rbac_utils.switch_role(self, toggle_rbac_role=True) self.domain_config_client.update_domain_config( self.domain_id, **updated_config)['config']
def test_update_endpoint(self): endpoint = self.setup_test_endpoint() new_url = data_utils.rand_url() self.rbac_utils.switch_role(self, toggle_rbac_role=True) self.endpoints_client.update_endpoint(endpoint["id"], url=new_url)
def test_identity_create_service_provider(self): self.do_request('create_service_provider', expected_status=exceptions.Forbidden, sp_id=data_utils.rand_name(), auth_url=data_utils.rand_url(), sp_url=data_utils.rand_url())