def get_service_url(region, endpoint_list, lookup): """Lookup a service URL from the *endpoint_list*. :param region: ``str`` :param endpoint_list: ``list`` :param lookup: ``str`` :return: ``object`` """ for endpoint in endpoint_list: region_get = endpoint.get("region", "") if region.lower() == region_get.lower(): return http.parse_url(url=endpoint.get(lookup)) else: raise exceptions.AuthenticationProblem('Region "%s" was not found in your Service Catalog.', region)
def get_service_url(region, endpoint_list, lookup): """Lookup a service URL from the *endpoint_list*. :param region: ``str`` :param endpoint_list: ``list`` :param lookup: ``str`` :return: ``object`` """ for endpoint in endpoint_list: region_get = endpoint.get('region', '') if region.lower() == region_get.lower(): return http.parse_url(url=endpoint.get(lookup)) else: raise exceptions.AuthenticationProblem( 'Region "%s" was not found in your Service Catalog.', region)
def test_parse_url_https_url(self): url = http.parse_url('https://example.com') self.assertEqual(type(url), http.urlparse.ParseResult) self.assertEqual(url.scheme, 'https')
def test_parse_url_double_slash_url(self): url = http.parse_url('//example.com') self.assertEqual(type(url), http.urlparse.ParseResult) self.assertEqual(url.scheme, 'http')
def test_parse_url_https_url(self): url = http.parse_url("https://example.com") self.assertEqual(type(url), http.urlparse.ParseResult) self.assertEqual(url.scheme, "https")
def test_parse_url_double_slash_url(self): url = http.parse_url("//example.com") self.assertEqual(type(url), http.urlparse.ParseResult) self.assertEqual(url.scheme, "http")